Mix of Bokeh plots and Datashader "InteractiveImage" in a single show()

I’m trying to develop a way to look at large spectral data, mixing both the raw spectral data (using datashader interactive image as the raw data is >8 million points), and simpler scatter plots to represent the data in another form.

For example, looking at mass spectral data. I have peak picked the data, and represent the picked peaks in a second type of plot (which I can do fine in Bokeh normally).
I want to overlay a scatter plot (~1000s of points) on top of the raw data (millions of points, line plot) and have them show together in such a way I can zoom into the interactive image, highlight the scatter points, and see them selected in the other plots.

I can do this fine if I just plot a line plot of the peak picked data, but obviously this isn’t the raw data.
I can get datashader to produce an interactive image of the raw data fine, but the documentation is a bit lacking for the InteractiveImage() function.

The basic datashader code is adapted from the Trajectory example https://anaconda.org/jbednar/trajectory/notebook

The final part is this:

p = base_plot()

InteractiveImage(p, create_image, throttle=200)

``

The bokeh code is just a couple of simple scatter or line plots, essentially this:

p1 = figure() #removed arguments for simplicity
p1.scatter() #removed arguments for simplicity
show(p1) # open a browser

``

Does this make sense?

Basically, is there a way to have the “interactive image” combined with other plots? Am I missing something obvious?

(For now I’m doing this in jupyter but I would like to get it working with bokeh serve eventually, though that is also proving tricky to get datashader to play ball with…)

Thanks

OK, so I got a bit further:

It is possible to do it -

p = base_plot()

p.scatter(x=‘Expmz’, y=‘RelAbun’,source=source, fill_color=‘black’,line_color=None)

InteractiveImage(p, create_image, throttle=200)

``

Any advice on A) if it is possible to include this figure in a tabbed layout with normal Bokeh plots?

Also, selecting points in the scatter did not automatically select them in the other plots, despite the source being defined the same. Is this normal?

···

On Monday, 9 May 2016 22:13:26 UTC+1, Will Kew wrote:

I’m trying to develop a way to look at large spectral data, mixing both the raw spectral data (using datashader interactive image as the raw data is >8 million points), and simpler scatter plots to represent the data in another form.

For example, looking at mass spectral data. I have peak picked the data, and represent the picked peaks in a second type of plot (which I can do fine in Bokeh normally).
I want to overlay a scatter plot (~1000s of points) on top of the raw data (millions of points, line plot) and have them show together in such a way I can zoom into the interactive image, highlight the scatter points, and see them selected in the other plots.

I can do this fine if I just plot a line plot of the peak picked data, but obviously this isn’t the raw data.
I can get datashader to produce an interactive image of the raw data fine, but the documentation is a bit lacking for the InteractiveImage() function.

The basic datashader code is adapted from the Trajectory example https://anaconda.org/jbednar/trajectory/notebook

The final part is this:

p = base_plot()

InteractiveImage(p, create_image, throttle=200)

``

The bokeh code is just a couple of simple scatter or line plots, essentially this:

p1 = figure() #removed arguments for simplicity
p1.scatter() #removed arguments for simplicity
show(p1) # open a browser

``

Does this make sense?

Basically, is there a way to have the “interactive image” combined with other plots? Am I missing something obvious?

(For now I’m doing this in jupyter but I would like to get it working with bokeh serve eventually, though that is also proving tricky to get datashader to play ball with…)

Thanks

Any advice on A) if it is possible to include this figure in a tabbed layout with normal Bokeh plots?

I can’t think of a specific reason why an InteractiveImage-based plot wouldn’t work alongside Bokeh plots, in principle, but InteractiveImage is definitely doing some work to control plot updating in a Jupyter notebook that may not play nicely with other Bokeh plots. We might be able to get that working nicely if you provide a concrete example with the full code as an issue at https://github.com/bokeh/datashader/issues . Hopefully you can make a version that doesn’t need 8 million points to show the problem. :slight_smile:

Also, selecting points in the scatter did not automatically select them in the other plots, despite the source being defined the same. Is this normal?

I’m not sure what you were hoping to work here. Above it sounds like you are overlaying scatter points on top of a datashader image, but here it sounds like you’re also laying out another Bokeh plot next to the overlaid plots? If that works when you don’t overlay with the datashader image, then we should be able to make it work when you do; again, a concrete example would let us investigate that. What won’t ever work with the current datashader code is to highlight individual points in the datashader image by selecting them in the Bokeh plot, but hopefully that’s not what you’re after.

(For now I’m doing this in jupyter but I would like to get it working with bokeh serve eventually, though that is also proving tricky to get datashader to play ball with…)

Making a version of InteractiveImage that works with bokeh serve is on our list (https://github.com/bokeh/datashader/issues/147).

HI James,

Thanks for that. Apologies for not including full code in the original post - size/confidentiality issues make it a bit of an issue.

I’ve put together some dummy (small) data and code to test it.

The ipython notebook demonstrates what I’m trying to achieve, I hope. Essentially I have (large) raw xy data which I want to plot with datashader.
I also have key highlights which have appropriate xy coordinates to be overlayed on the datashader image. These highlights have other associates parameters (A,B and Age, Height).
I then plot those other things as simple scatter bokeh plots. I can interact with one bokeh plot (box select) and see the same points highlighted in the other bokeh scatter plot. However, when I try to highlight the scatter points which are overlayed on a datashader plot, there is no follow through?

Also, is it possible to include the interactive image in the “hplot” or in a tabbed plot? (i.e. to be shown with the other two plots, not just below it).

···

On Monday, 9 May 2016 23:38:30 UTC+1, James A. Bednar wrote:

Any advice on A) if it is possible to include this figure in a tabbed layout with normal Bokeh plots?

I can’t think of a specific reason why an InteractiveImage-based plot wouldn’t work alongside Bokeh plots, in principle, but InteractiveImage is definitely doing some work to control plot updating in a Jupyter notebook that may not play nicely with other Bokeh plots. We might be able to get that working nicely if you provide a concrete example with the full code as an issue at https://github.com/bokeh/datashader/issues . Hopefully you can make a version that doesn’t need 8 million points to show the problem. :slight_smile:

Also, selecting points in the scatter did not automatically select them in the other plots, despite the source being defined the same. Is this normal?

I’m not sure what you were hoping to work here. Above it sounds like you are overlaying scatter points on top of a datashader image, but here it sounds like you’re also laying out another Bokeh plot next to the overlaid plots? If that works when you don’t overlay with the datashader image, then we should be able to make it work when you do; again, a concrete example would let us investigate that. What won’t ever work with the current datashader code is to highlight individual points in the datashader image by selecting them in the Bokeh plot, but hopefully that’s not what you’re after.

(For now I’m doing this in jupyter but I would like to get it working with bokeh serve eventually, though that is also proving tricky to get datashader to play ball with…)

Making a version of InteractiveImage that works with bokeh serve is on our list (https://github.com/bokeh/datashader/issues/147).