单击按钮后清除并重新绘制图形

时间:2018-04-19 08:37:16

标签: python plot bokeh

我使用“for”循环在点击按钮后以交互方式绘制我的数据,它获取新值并计算数据然后绘制它。我的问题是,在输入新值后,绘图历史记录不清晰,输出中显示新/旧绘图,这是不合适的。如何清除和重绘我的绘图数据:

p = figure(plot_height=600, plot_width=700,x_axis_type="datetime", title="Plot Data", toolbar_location=None, tools='')
p.legend.location = "top_left"
p.legend.orientation = "vertical"
p.legend.click_policy = "hide"  # hide legend by clicking on legend entry
#p.title.text = ('Click on legend entry to hide related line')
p.legend.border_line_color = 'green'


def plot_update(X,Y,legend,pallete):
    reset_output()
    for (col, leg, x, y) in zip(pallete, legend, X, Y):
        my_plot = p.line(x, y, color=col, legend=leg, line_width=2)
    return p

0 个答案:

没有答案