I'm lost as to how to set up a Column Data Source so that I can select points from one graph and have the corresponding points highlighted in another graph. I am trying to learn more about how this works.
The sample code I am using is the example called Linked Brushing. I'd like to see if I can get the same effect with my own code, below. That web page explanation also refers to Linked Selection with Filtered Data but I don't understand what the code filters=[BooleanFilter([True if y > 250 or y < 100 else False for y in y1]
on that page does, so I'm not sure how to adapt it, or if it's even relevant.
Here is my code:
from bokeh.plotting import figure, output_file, show, Column
from bokeh.models import ColumnDataSource, CDSView, BooleanFilter
from MyFiles import *class bokehPlot:def __init__(self, filename, t, a, b, c, d):self.source = ColumnDataSource(data=dict(x=t, y1=a, y2=b, y3=c, y4=d))p1 = self.makePlot(filename, 'x', 'y1', 'A')p2 = self.makePlot(filename, 'x', 'y2', 'B', x_link=p1)p3 = self.makePlot(filename, 'x', 'y3', 'C', x_link=p1)p4 = self.makePlot(filename, 'x', 'y4', 'D', x_link=p1)output_file('scatter_plotting.html', mode='cdn')p = Column(p1, p2, p3, p4)show(p)def makePlot(self,filename,x0,y0,y_label, **optional):TOOLS = "box_zoom,box_select,reset"p = figure(tools=TOOLS, plot_width=1800, plot_height=300)if ('x_link' in optional):p0 = optional['x_link']p.x_range = p0.x_rangep.scatter(x=x0, y=y0, marker='square', size=1, fill_color='red', source=self.source)p.title.text = filenamep.title.text_color = 'orange'p.xaxis.axis_label = 'T'p.yaxis.axis_label = y_labelp.xaxis.minor_tick_line_color = 'red'p.yaxis.minor_tick_line_color = Nonereturn p
And my main looks like this (set to pass along up to 100K data points from the file):web
p = readMyFile(path+filename+extension, 100000)
t = p.time()
a = p.a()
b = p.b()
c = p.c()
d = p.d()
v = bokehPlot(filename, t, a, b, c, d)
The variables t, a, b, c, and d are type numpy ndarray.
I've managed to link the plots so I can pan and zoom them all from one graph. I would like to grab a cluster of data from one plot and see them highlighted, along with the corresponding values (at the same t values) highlighted on the other graphs.
In this code, I can draw a selection box, but it just remains for a moment, then disappears, and I see no effect on any plot. How is the box_select linked to the source and what causes the plots to redraw?
This is just one step in trying to familiarize myself with Bokeh. My next goal will be to use TSNE to cluster my data and show the clusters with synchronized colors in each graph. But first, I want to understand the mechanics of using the column data set here. In the sample code, for example, I don't see any explicit connection between the box_select operation and the source variable and what causes the plot to redraw.