This documentation is for the older Mesmerize legacy desktop application. Please see the home page or GitHub repo for information on the latest packages.



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


highlight_mode – Interactive mode, one of ‘row’ or ‘item’

set_data(dataframes: Union[DataFrame, list], data_column: str, labels_column: str, cmap: str = 'jet', transmission: Optional[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.


column – DataFrame column containing categorical values used for sorting the heatmap rows

set_transmission(transmission: Transmission)[source]

Set the input transmission

get_transmission() 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: BasePlotWidget, 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


The embedded Datapoint Tracer <API_DatapointTracer>

set_update_live(*args, **kwds)

Must be implemented in subclass

set_current_datapoint(ix: tuple)[source]

Set the currently selected datapoint in the Datapoint Tracer.


ix – index, (x, y). x is always 0 for this widget since it only uses ‘row’ selection mode and not ‘item’

set_input(*args, **kwds)

Set the input Transmission with data to plot


transmission – Input transmission

set_input(*args, **kwds)

Set the input Transmission with data to plot


transmission – Input transmission

get_plot_opts(drop: bool = False) dict[source]

Get the plot options


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

set_plot_opts(*args, **kwds)

Must be implemented in subclass


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

get_cluster_kwargs() dict[source]

Organize kwargs for visualization of hierarchical clustering

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

property transmission: Transmission

The input transmission

Return type:


save_plot_dialog(path, *args)

Plot save 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


path – Path to save the file to. For easy identification use “.ptrn” extension.

open_plot_dialog(filepath, dirpath, *args, **kwargs)

Open plot dialog

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.


Lower level widget that handles the actual plotting and user interaction

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

Bases: MatplotlibWidget

Heatmap plot variant


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


highlight_mode – The selection mode for the heatmap. One of either ‘row’ or ‘item’


2D numpy array of the heatmap data


Selection instance that organizes mouse click events on the heatmap


ClusterGrid object instance containing the plot Axes

set(data: ndarray, *args, ylabels: Optional[Union[Series, ndarray, list]] = None, ylabels_cmap: str = 'tab20', cluster_kwargs: Optional[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