在绘制新图形之前使用 IPython 小部件清除 jupyter notebook 上的图形

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

这是我的代码。我想单击按钮绘制图形,然后在单击按钮绘制新图形之前删除绘制的图形。

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)

在情节陈述之前使用 clear_output()