1

So I'm trying to create a cell that refreshes plots using a slider. Here is the code,

slider = FloatSlider(0.1)
slider.max = 1
slider.min = 0
plt.plot(figsize=(15,10))

def plot_corr_graph_summary(lod):
    plt.clf()
    corrMatrix_Crushed = df_summary_virtual_physical_split.iloc[:,int(lod):].corr()
    sns.heatmap(corrMatrix_Crushed, annot=False)
    plt.show()

def level_of_detail(change):
    if slider.value >= 0.2:
        plot_corr_graph_summary(6-slider.value*10)

slider.observe(level_of_detail, 'value')
slider

The result looks like,

Output

How do I make the plots overwrite one another, I am trying to use plt.clf() in my function but nothing seems to be happening.

1 Answer 1

1

Got it!

using

from IPython.display import clear_output

The cell output is HTML! Need to flush that, not the plot.

clear_output()

Will do the trick.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.