plot2d#
- class braintools.visualize.morphology.plot2d(morpho, *, region=None, locset=None, values=None, cmap=None, vmin=None, vmax=None, norm=None, value_label=None, show_colorbar=True, layout=None, shape=None, branch_type_colors=None, branch_type_edge_colors_2d=None, frustum_edge_linewidth_2d=None, backend=None, chooser=None, ax=None, notebook=None, jupyter_backend=None, return_plotter=False, projection_plane='xy', min_branch_angle_deg=25.0, root_layout='type_split', layout_config=None, hooks=None)[source]#
Draw a morphology in 2-D with Matplotlib.
layoutdecides where the branches go andshapehow they are drawn."projected"drops one axis of the 3-D points;"fan","stem","balloon"and"radial_360"are schematic layouts computed from branch lengths and topology, so they also work for morphologies without point geometry.- Parameters:
morpho (MorphologyData-like) – A
MorphologyDataor any object implementing__morphology_data__().region (RegionData-like, optional) – Intervals
(branch_index, prox, dist)to highlight.locset (LocsetData-like, optional) – Points
(branch_index, x)to mark.values (array-like, optional) – Scalars to colour-map, one per branch, per segment or per centerline point (inferred from the length; pass a
ValueSpecwithspaceto state it).cmap (
str|None) – Colour-mapping settings forvalues; seeValueSpec.vmin (
float|None) – Colour-mapping settings forvalues; seeValueSpec.vmax (
float|None) – Colour-mapping settings forvalues; seeValueSpec.norm – Colour-mapping settings for
values; seeValueSpec.value_label (
str|None) – Colour-mapping settings forvalues; seeValueSpec.show_colorbar (
bool) – Colour-mapping settings forvalues; seeValueSpec.layout (
str|None) – Defaults toVisDefaults.layout_2d_default("fan").shape (
str|None) – Defaults toVisDefaults.shape_2d_default("frustum")."projected"supports"line"only.branch_type_colors (
dict[str,object] |None) – Style overrides for this call only.branch_type_edge_colors_2d (
dict[str,object] |None) – Style overrides for this call only.frustum_edge_linewidth_2d (
float|None) – Style overrides for this call only.backend (
str|None) – Backend name;"matplotlib"is the only 2-D backend.chooser (
BackendChooser|None) – Explicit backend chooser.ax (matplotlib.axes.Axes, optional) – Axes to draw into; a new figure is created otherwise.
notebook (
bool|None) – Display options forwarded to the backend.jupyter_backend (
str|None) – Display options forwarded to the backend.return_plotter (
bool) – Display options forwarded to the backend.projection_plane (
str) – Axis pair forlayout="projected".min_branch_angle_deg (
float|None) – Minimum angle between sibling branches in schematic layouts.root_layout (
str) – How the root’s children are arranged in schematic layouts.layout_config (
LayoutConfig|None) – Fine-grained layout parameters.
- Returns:
The axes drawn into.
- Return type:
- Raises:
TypeError – If
morphois not morphology data.ValueError – If
layout="projected"is used without full point geometry or withshape="frustum", or if an option is not recognised.
See also
plot3d3-D rendering with PyVista or Plotly.
compare_morphologiesSeveral morphologies side by side.
Examples
>>> import brainunit as u >>> from braintools.visualize.morphology import BranchData, MorphologyData, plot2d >>> soma = BranchData( ... index=0, name="soma", type="soma", parent_index=None, ... parent_x=None, child_x=None, lengths=[20.0] * u.um, ... radii_proximal=[10.0] * u.um, radii_distal=[10.0] * u.um, ... ) >>> dend = BranchData( ... index=1, name="dend", type="basal_dendrite", parent_index=0, ... parent_x=1.0, child_x=0.0, lengths=[50.0, 50.0] * u.um, ... radii_proximal=[1.0, 0.8] * u.um, radii_distal=[0.8, 0.5] * u.um, ... ) >>> ax = plot2d(MorphologyData(branches=(soma, dend)), layout="stem")