9

Is there a way to have Bokeh plot data that has gaps in it? See the below screenshot from a Excel plot for an example. I tried using None values, but it just plotted zero values.

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

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

Excel Plot

feik
  • 367
  • 2
  • 17

1 Answers1

10

You can use nan (here I've used np.nan, after import numpy as np, but float("nan") would work as well):

>>> 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

demo of gap

DSM
  • 342,061
  • 65
  • 592
  • 494