更新Jupiter noteb中的bokeh补丁

2024-06-01 06:34:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我很好奇的正确方法来更新补丁铭文在博凯。 我最简单的例子是:

p_blur = figure(x_range=(0, 300), y_range=(0, 300))
source = ColumnDataSource({'xs':[[100,200,300], [10,50,500,400]], 'ys':[[30,150,70], [10,500,50,50]]})
polygons = Patches(xs="xs", ys="ys",fill_color="#fb9a99")
glyph = p_blur.add_glyph(source, polygons)
nb = show(p_blur, notebook_handle=True)

如果我现在想更新glyph,例如

source1 = ColumnDataSource({'xs':[[10,20,30], [10,50,50,40]], 'ys':[[30,15,70], [10,50,50,50]]})
glyph.data_source = source1
push_notebook( nb )

我看不出有什么变化。但是,如果我这样做:

p_blur.renderers.remove(glyph)
glyph = p_blur.add_glyph(source1, polygons)
push_notebook( nb ) 

这一变化得到了反映。看来第二条路太黑了。有没有更正确的方法?你知道吗

谢谢!你知道吗


Tags: 方法addsourcerangepushnotebookxsnb