☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

ploting sparse data

Community Support
web.rishi.shukla
web.rishi.shukla

I am plotting a line where :

x axis is Timestamp. eg. T1, T2, → T20

y axis is a Stat Value eg. … … … 10 20 30

… indicates that there is no value for the stat for that timestamp.

The line is plotted using this call:

            figure.line (x_axis, this_bucket_plot, legend=bucket, alpha=0.5, color=this_color, line_width=3)

x_axis is an array of x axis datapoints
this_bucket_plot is an array of y axis datapoints.

Most of the datapoints in this_bucket_plot as intentionally set to 0 so that lenght of both arrays is same.
To save processing time, is there a way to indicate bokeh not to plot 0 values. Most of my data is sparse i.e. 0.
⌁   Link to post
Bryan
Bryan

Hi,

There are certainly ways to do this on the client side with CustomJSTransform, etc. but if the goal is to not send the data in the first place, then you should cut the data down first on the python side. Something like:

  In [1]: import numpy as np
  
  In [2]: x = np.arange(10)
  
  In [3]: y = np.zeros_like(x)
  
  In [4]: y[1] = 1; y[4:7] = 1
  
  In [5]: x
  Out[5]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
  
  In [6]: y
  Out[6]: array([0, 1, 0, 0, 1, 1, 1, 0, 0, 0])
  
  In [7]: x[y>0]
  Out[7]: array([1, 4, 5, 6])
  
  In [8]: y[y>0]
  Out[8]: array([1, 1, 1, 1])

Thanks,

Bryan

···

On May 23, 2018, at 12:46, web.rishi.shukla@gmail.com wrote:

I am plotting a line where :

x axis is Timestamp. eg. T1, T2, -> T20
y axis is a Stat Value eg. .. .. .. 10 20 30

.. indicates that there is no value for the stat for that timestamp.

The line is plotted using this call:
figure.line (x_axis, this_bucket_plot, legend=bucket, alpha=0.5,
            color=this_color, line_width=3)

x_axis is an array of x axis datapoints
this_bucket_plot is an array of y axis datapoints.

Most of the datapoints in this_bucket_plot as intentionally set to 0 so that lenght of both arrays is same.
To save processing time, is there a way to indicate bokeh not to plot 0 values. Most of my data is sparse i.e. 0.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/46363223-f8e9-4e4c-810e-57f5d7620a13%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled