brian2tools.plotting.morphology module¶
Module to plot Brian Morphology
objects.
-
brian2tools.plotting.morphology.
plot_morphology
(morphology, plot_3d=None, show_compartments=False, show_diameter=False, colors=('darkblue', 'darkred'), values=None, value_norm=(None, None), value_colormap='hot', value_colorbar=True, value_unit=None, axes=None)[source]¶ Plot a given
Morphology
in 2D or 3D.Parameters: - morphology (
Morphology
) – The morphology to plot - plot_3d (bool, optional) – Whether to plot the morphology in 3D or in 2D. If not set (the default) a morphology where all z values are 0 is plotted in 2D, otherwise it is plot in 3D.
- show_compartments (bool, optional) – Whether to plot a dot at the center of each compartment. Defaults to
False
. - show_diameter (bool, optional) – Whether to plot the compartments with the diameter given in the
morphology. Defaults to
False
. - colors (sequence of color specifications) – A list of colors that is cycled through for each new section. Can be
any color specification that matplotlib understands (e.g. a string such
as
'darkblue'
or a tuple such as(0, 0.7, 0)
. - values (Quantity, optional) – Values to fill compartment patches with a color that corresponds to their given value.
- value_norm (tuple or callable, optional) – Normalization function to scale the displayed values. Can be a tuple
of a minimum and a maximum value (where either of them can be
None
to denote taking the minimum/maximum from the data) or a function that takes a value and returns the scaled value (e.g. as returned bymatplotlib.colors.PowerNorm
). For a tuple of values, will usematplotlib.colors.Normalize```(vmin, vmax, clip=True)``
with the given(vmin, vmax)
values. - value_colormap (str or matplotlib.colors.Colormap, optional) – Desired colormap for plots. Either the name of a standard colormap
or a
matplotlib.colors.Colormap
instance. Defaults to'hot'
. Note that this usesmatplotlib
color maps even for 3D plots with Mayavi. - value_colorbar (bool or dict, optional) – Whether to add a colorbar for the
values
. Defaults toTrue
, but will be ignored if novalues
are provided. Can also be a dictionary with the keyword arguments for matplotlib’scolorbar
method (2D plot), or for Mayavi’sscalarbar
method (3D plot). - value_unit (
Unit
, optional) – AUnit
to rescale the values for display in the colorbar. Does not have any visible effect if no colorbar is used. If not specified, will try to determine the “best unit” to itself. - axes (
Axes
orScene
, optional) – A matplotlibAxes
(for 2D plots) or mayaviScene
( for 3D plots) instance, where the plot will be added.
Returns: axes – The
Axes
orScene
instance that was used for plotting. This object allows to modify the plot further, e.g. by setting the plotted range, the axis labels, the plot title, etc.Return type: - morphology (
-
brian2tools.plotting.morphology.
plot_dendrogram
(morphology, axes=None)[source]¶ Plot a “dendrogram” of a morphology, i.e. an abstract representation which visualizes the branching structure and the length of each section.
Parameters: - morphology (
Morphology
) – The morphology to visualize. - axes (
Axes
, optional) – TheAxes
instance used for plotting. Defaults toNone
which means that a newAxes
will be created for the plot.
Returns: axes – The
Axes
instance that was used for plotting. This object allows to modify the plot further, e.g. by setting the plotted range, the axis labels, the plot title, etc.Return type: - morphology (