简体   繁体   English

散景 - 用空隙绘制数据

[英]Bokeh - Plotting Data with Gaps

Is there a way to have Bokeh plot data that has gaps in it? 有没有办法让Bokeh绘图数据有差距呢? See the below screenshot from a Excel plot for an example. 有关示例,请参阅Excel绘图中的以下屏幕截图。 I tried using None values, but it just plotted zero values. 我尝试使用None值,但它只是绘制了零值。

x_data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] x_data = [1,2,3,4,5,6,7,8,9,10]

y_data = [4, 1, 2, 3, , , , 4, 4, 5] y_data = [4,1,2,3 ,,,,4,4,5]

Excel图

You can use nan (here I've used np.nan , after import numpy as np , but float("nan") would work as well): 你可以使用nan (这里我使用了np.nan ,在import numpy as np ,但float("nan")也可以使用):

>>> y_data = [4, 1, 2, 3, np.nan, np.nan, np.nan, 4, 4, 5]
>>> x_data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> p1 = figure(plot_width=600, plot_height=400)
>>> p1.line(x_data, y_data, size=12, color="blue")

gives

差距的演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM