cytoflow.views.densityplot

Plot a 2D density plot.

DensityView – the IView class that makes the plot.

class cytoflow.views.densityplot.DensityView[source]

Bases: cytoflow.views.base_views.Base2DView

Plots a 2-d density plot.

huefacet

You must leave the hue facet unset!

Type

None

xchannel

The channel to view on the X axis

Type

Str

ychannel

The channel to view on the Y axis

Type

Str

xscale

The scales applied to the xchannel data before plotting it.

Type

{‘linear’, ‘log’, ‘logicle’} (default = ‘linear’)

yscale

The scales applied to the ychannel data before plotting it.

Type

{‘linear’, ‘log’, ‘logicle’} (default = ‘linear’)

subset

An expression that specifies the subset of the statistic to plot. Passed unmodified to pandas.DataFrame.query.

Type

str

xfacet

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

Type

String

yfacet

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

Type

String

huescale

How should the color scale for huefacet be scaled?

Type

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

Examples

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.DensityView(xchannel = 'V2-A',
...                 xscale = 'log',
...                 ychannel = 'Y2-A',
...                 yscale = 'log').plot(ex)
../../_images/cytoflow-views-densityplot-2.png

The same plot, smoothed, with a log color scale. Note - you can change the hue scale, even if you don’t have control over the hue facet!

>>> flow.DensityView(xchannel = 'V2-A',
...                  xscale = 'log',
...                  ychannel = 'Y2-A',
...                  yscale = 'log',
...                  huescale = 'log').plot(ex, smoothed = True)
../../_images/cytoflow-views-densityplot-3.png
plot(experiment, **kwargs)[source]

Plot a faceted density plot view of a channel

Parameters
  • experiment (Experiment) – The Experiment to plot using this view.

  • title (str) – Set the plot title

  • xlabel (str) – Set the X axis label

  • ylabel (str) – Set the Y axis label

  • 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 (bool) – If there are multiple subplots, should they share X axes? Defaults to True.

  • sharey (bool) – If there are multiple subplots, should they share Y axes? Defaults to True.

  • row_order (list) – Override the row 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.

  • col_order (list) – Override the column 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.

  • hue_order (list) – Override the 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 this 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.

  • palette (palette name, list, or dict) – Colors to use for the different levels of the hue variable. Should be something that can be interpreted by seaborn.color_palette, or a dictionary mapping hue levels to matplotlib colors.

  • 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 ((float, float)) – Set the range of the plot’s X axis.

  • ylim ((float, float)) – Set the range of the plot’s Y axis.

  • gridsize (int) – The size of the grid on each axis. Default = 50

  • smoothed (bool) – Should the resulting mesh be smoothed?

  • smoothed_sigma (int) – The standard deviation of the smoothing kernel. default = 1.

  • cmap (cmap) – An instance of matplotlib.colors.Colormap. By default, the viridis colormap is used

  • under_color (matplotlib color) – Sets the color to be used for low out-of-range values.

  • bad_color (matplotlib color) – Set the color to be used for masked values.

Notes

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