user8183395
user8183395

Reputation: 115

Clear plot on jupyter notebook with IPython widget before plotting a new graph

This is my code. I'd like to click the button plot the graph and then remove the graph plotted before plotting a new graph on clicking the button.

columns=[i for i in load_weekday['feed_point_number'].unique()]

selection=widgets.Dropdown(description='Select feed_point_number?')
selection.options=columns
display(selection)

def on_button_clicked(b):
    sns.set_style("whitegrid")
    sns.set_context(rc={"figure.figsize":(12,9)})
    load_weekday.plot(x='time_code',y=selection.value,color='Blue')
button=widgets.Button(description="Plot")
display(button)

button.on_click(on_button_clicked)

Upvotes: 0

Views: 1689

Answers (1)

user3687197
user3687197

Reputation: 181

use clear_output() before your plot statement

Upvotes: 1

Related Questions