class cytoflow.views.histogram_2d.Histogram2DView[source]

Bases: cytoflow.views.base_views.Base2DView

Plots a 2-d histogram. Similar to a density plot, but the number of events in a bin change the bin’s opacity, so you can use different colors.

xchannel, ychannel

The channels to view

xscale, yscale

The scales applied to the data before plotting it.

Type:{‘linear’, ‘log’, ‘logicle’} (default = ‘linear’)
xlim, ylim

Set the min and max limits of the plots’ x and y axes.

Type:(float, float)
xfacet, yfacet

Set to one of the conditions in the Experiment, and a new row or column of subplots will be added for every unique value of that condition.


Set to one of the conditions in the in the Experiment, and a new color will be added to the plot for every unique value of that condition.


How should the color scale for huefacet be scaled?

Type:{‘linear’, ‘log’, ‘logicle’}


Make a little data set.

>>> import cytoflow as flow
>>> import_op = flow.ImportOp()
>>> import_op.tubes = [flow.Tube(file = "Plate01/RFP_Well_A3.fcs",
...                              conditions = {'Dox' : 10.0}),
...                    flow.Tube(file = "Plate01/CFP_Well_A4.fcs",
...                              conditions = {'Dox' : 1.0})]
>>> import_op.conditions = {'Dox' : 'float'}
>>> ex = import_op.apply()

Plot a density plot

>>> flow.Histogram2DView(xchannel = 'V2-A',
...                      xscale = 'log',
...                      ychannel = 'Y2-A',
...                      yscale = 'log',
...                      huefacet = 'Dox').plot(ex)

The same plot, smoothed, with a log color scale.

>>> flow.Histogram2DView(xchannel = 'V2-A',
...                      xscale = 'log',
...                      ychannel = 'Y2-A',
...                      yscale = 'log',
...                      huefacet = 'Dox',
...                      huescale = 'log').plot(ex, smoothed = True)
id = ''
friend_id = '2D Histogram'
plot(experiment, **kwargs)[source]

Plot a faceted density plot view of a channel

  • experiment (Experiment) – The Experiment to plot using this view.
  • title (str) – Set the plot title
  • xlabel, ylabel (str) – Set the X and Y axis labels
  • huelabel (str) – Set the label for the hue facet (in the legend)
  • legend (bool) – Plot a legend for the color or hue facet? Defaults to True.
  • sharex, sharey (bool) – If there are multiple subplots, should they share axes? Defaults to True.
  • row_order, col_order, hue_order (list) – Override the row/column/hue facet value order with the given list. If a value is not given in the ordering, it is not plotted. Defaults to a “natural ordering” of all the values.
  • height (float) – The height of each row in inches. Default = 3.0
  • aspect (float) – The aspect ratio of each subplot. Default = 1.5
  • col_wrap (int) – If xfacet is set and yfacet is not set, you can “wrap” the subplots around so that they form a multi-row grid by setting col_wrap to the number of columns you want.
  • sns_style ({“darkgrid”, “whitegrid”, “dark”, “white”, “ticks”}) – Which seaborn style to apply to the plot? Default is whitegrid.
  • sns_context ({“paper”, “notebook”, “talk”, “poster”}) – Which seaborn context to use? Controls the scaling of plot elements such as tick labels and the legend. Default is talk.
  • despine (Bool) – Remove the top and right axes from the plot? Default is True.
  • min_quantile (float (>0.0 and <1.0, default = 0.001)) – Clip data that is less than this quantile.
  • max_quantile (float (>0.0 and <1.0, default = 1.00)) – Clip data that is greater than this quantile.
  • xlim, ylim ((float, float)) – Set the range of the plot’s axis.
  • gridsize (int) – The number of bins on the X and Y axis.
  • smoothed (bool) – Should the mesh be smoothed?
  • smoothed_sigma (int) – The standard deviation of the smoothing kernel. default = 1.


Other kwargs are passed to matplotlib.axes.Axes.pcolormesh

class cytoflow.views.histogram_2d.AlphaColormap(name, color, min_alpha=0.0, max_alpha=1.0, N=256)[source]

Bases: matplotlib.colors.Colormap