-
Is there a way to plot multiple gates on a single plot when the gates are defined in the same dimension(s). My immediate use case are 'bisector' gates which are two 1-D RectangleGates which have just a min or max defined. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Karl, The import bokeh
from bokeh.plotting import show
import flowkit as fk
bokeh.io.output_notebook()
# Create Session, add a sample
session = fk.Session()
data1_sample = fk.Sample("../../../data/gate_ref/data1.fcs")
session.add_samples(data1_sample)
# Define 2 range gates & add to Session
range1_dim1 = fk.Dimension("FSC-H", compensation_ref="uncompensated", range_min=100)
range1_dims = [range1_dim1]
range1_gate = fk.gates.RectangleGate("Range1", range1_dims)
range2_dim1 = fk.Dimension("FSC-H", compensation_ref="uncompensated", range_max=47)
range2_dims = [range2_dim1]
range2_gate = fk.gates.RectangleGate("Range2", range1_dims)
session.add_gate(range1_gate, ("root",))
session.add_gate(range2_gate, ("root",))
# plot the 'Range1' gate to get a Bokeh figure
# We could show the plot here, but we just want the figure object
p = session.plot_gate(data1_sample.id, 'Range1')
# Here's the call to the private plot_utils function
renderers = fk._utils.plot_utils.render_ranges(dim_minimums=[None], dim_maximums=[range2_dim1.max])
# Add the renderers to the Bokeh figure
p.renderers.extend(renderers)
# show the plot
show(p) Hope this helps, |
Beta Was this translation helpful? Give feedback.
Hi Karl,
The
Session.plot_gate()
method doesn't have any options to plot 2 gates. However, the plot objects returned are Bokeh figure instances so can be modified to add extra items. There are private helper methods to render the various gate shapes, so you could use these to achieve this. I'll add an example below to show how this is done. Be aware the plot_utils render functions are not public though I have no plans to change them so should be stable to use.