Higher level widgets that are directly used by the end-user. Both Heatmap widgets use the same plot variant.


Heatmap with a vertical splitter that can be used to house another widget. The plot is compatible with both ‘row’ and ‘item’ selection modes.

class mesmerize.plotting.HeatmapSplitterWidget(highlight_mode='row')[source]

Widget for interactive heatmaps

Parameters:highlight_mode – Interactive mode, one of ‘row’ or ‘item’
set_data(dataframes: Union[pandas.core.frame.DataFrame, list], data_column: str, labels_column: str, cmap: str = 'jet', transmission: Optional[mesmerize.analysis.data_types.Transmission] = None, sort: bool = True, reset_sorting: bool = True, **kwargs)[source]

Set the data and then set the plot

  • dataframes – list of dataframes or a single DataFrame
  • data_column – data column of the dataframe that is plotted in the heatmap
  • labels_column – dataframe column (usually categorical labels) used to generate the y-labels and legend.
  • cmap – colormap choice
  • transmission – transmission object that dataframe originates, used to calculate data units if passed
  • sort – if False, the sort comboBox is ignored
  • reset_sorting – reset the order of the rows in the heatmap
  • kwargs – Passed to Heatmap.set
_set_sort_order(column: str)[source]

Set the sort order of the heatmap rows according to a dataframe column. The column must contain categorical values. The rows are grouped together according to the categorical values.

Parameters:column – DataFrame column containing categorical values used for sorting the heatmap rows
set_transmission(transmission: mesmerize.analysis.data_types.Transmission)[source]

Set the input transmission

get_transmission() → mesmerize.analysis.data_types.Transmission[source]

Get the input transmission

highlight_row(ix: int)[source]

Highlight a row on the heatmap


Heatmap with an embedded Datapoint Tracer that can be saved and restored.

class mesmerize.plotting.HeatmapTracerWidget[source]

Bases: mesmerize.plotting.widgets.base.BasePlotWidget, mesmerize.plotting.widgets.heatmap.widget.HeatmapSplitterWidget

Heatmap with an embedded datapoint tracer

drop_opts = ['dataframes', 'transmission']

keys of the plot_opts dict that are not JSON compatible and not required for restoring this plot

live_datapoint_tracer = None

The embedded Datapoint Tracer <API_DatapointTracer>

set_current_datapoint(ix: tuple)[source]

Set the currently selected datapoint in the Datapoint Tracer.

Parameters:ix – index, (x, y). x is always 0 for this widget since it only uses ‘row’ selection mode and not ‘item’
get_plot_opts(drop: bool = False) → dict[source]

Get the plot options

Parameters:drop – Drop the non-json compatible objects that are not necessary to restore this plot

Calls set_data and passes dict from get_plot_opts() as keyword arguments

set_data(*args, datapoint_tracer_curve_column: str = None, **kwargs)[source]

Set the plot data, parameters and draw the plot. If the input Transmission comes directly from the FCluster it will pass a dict from get_cluster_kwargs() to the cluster_kwargs argument. Else it will pass None to cluster_kwargs.

  • args – arguments to pass to superclass set_data() method
  • datapoint_tracer_curve_column – Data column containing curves to use in the datapoint tracer
  • kwargs – keyword arguments, passed to superclass set_data() method
open_plot(ptrn_path: str, proj_path: str) → Optional[Tuple[str, str]]

Open a plot saved by the save_plot() method

  • ptrn_path – Path to the HDF5 Transmission file. By convention file extension is “.ptrn”
  • proj_path – Project path of the associated plot data.
open_plot_dialog(filepath, dirpath, *args, **kwargs)

Open plot dialog


Save the plot as a Transmission in an HDF5 file. Plot parameters are stored as a JSON string within the HDF5 file. See Transmission.to_hdf5

Parameters:path – Path to save the file to. For easy identification use “.ptrn” extension.
save_plot_dialog(path, *args)

Plot save dialog


The input transmission

Return type:Transmission


Lower level widget that handles the actual plotting and user interaction

class mesmerize.plotting.variants.Heatmap(highlight_mode='row')[source]

Bases: mesmerize.pyqtgraphCore.widgets.MatplotlibWidget.MatplotlibWidget

Heatmap plot variant


Emits indices of data coordinates (x, y) from mouse-click events on the heatmap

Parameters:highlight_mode – The selection mode for the heatmap. One of either ‘row’ or ‘item’
data = None

2D numpy array of the heatmap data

selector = None

Selection instance that organizes mouse click events on the heatmap

plot = None

ClusterGrid object instance containing the plot Axes

set(data: numpy.ndarray, *args, ylabels: Union[pandas.core.series.Series, numpy.ndarray, list] = None, ylabels_cmap: str = 'tab20', cluster_kwargs: dict = None, **kwargs)[source]
  • data – 2D numpy array
  • args – Additional args that are passed to sns.heatmap()
  • ylabels – Labels used to create the ylabels bar
  • ylabels_cmap – colormap for the ylabels bar
  • cluster_kwargs – keywoard arguments for visualizing hierarchical clustering
  • kwargs – Additional kwargs that are passed to sns.heatmap()
add_stimulus_indicator(start: int, end: int, color: str)[source]

Add lines to indicate the start and end of a stimulus or behavioral period

  • start – start index
  • end – end index
  • color – line color