Plotting

The nanomesh.plotting module helps with plotting meshes.

Functions

These plotting functions are currently available:

meshplot(mesh[, ax, key, legend, ...])

Plot a nanomesh.TriangleMesh or nanomesh.LineMesh using matplotlib.

linemeshplot(mesh[, ax, key, legend, ...])

Alias for meshplot().

trianglemeshplot(mesh[, ax, key, legend, ...])

Alias for meshplot().

linetrianglemeshplot(mesh, **kwargs)

Plot line/triangle mesh together.

lineplot(ax, *, x, y, cells[, mask, label])

Plot collection of line segments.

pointsplot(mesh[, key, ax])

Plot mesh points.

Reference

nanomesh.plotting.meshplot(mesh: LineMesh | TriangleMesh, ax: plt.Axes = None, key: str = None, legend: str = 'fields', show_labels: Optional[Iterable | str | int] = None, hide_labels: Optional[Iterable | str | int] = None, show_region_markers: bool = True, colors: Sequence[str] = None, color_map: Dict[str | int, str] = None, flip_xy: bool = True, **kwargs) plt.Axes[source]

Plot a nanomesh.TriangleMesh or nanomesh.LineMesh using matplotlib.

Parameters
  • ax (matplotlib.axes.Axes, optional) – Axes to use for plotting.

  • key (str, optional) – Label of cell data item to plot, defaults to nanomesh.LineMesh.default_key or nanomesh.TriangleMEsh.default_key.

  • legend (str) – Style for the legend. - off : No legend - all : Create legend with all labels - fields : Create legend with field names only - floating : Add floating labels to plot

  • show_labels (Iterable | str | int) – List of labels or field names of cell data to show. A single label to show can also be specified directly by its name or number.

  • hide_labels (Iterable | str | int) – List of labels or field names of cell data to hide. A single label to hide can also be specified directly by its name or number.

  • show_region_markers (bool, default True) – If True, show region markers on the plot

  • colors (Sequence[str]) – List of colors to cycle through

  • color_map (dict) – Mapping of labels or field names to colors.

  • flip_xy (bool, optional) – Flip x/y coordinates. This is sometimes necessary to combine the plot with other plots.

  • **kwargs – These parameters are passed to lineplot() or triplot().

Return type

matplotlib.axes.Axes

nanomesh.plotting.linemeshplot(mesh: LineMesh | TriangleMesh, ax: plt.Axes = None, key: str = None, legend: str = 'fields', show_labels: Optional[Iterable | str | int] = None, hide_labels: Optional[Iterable | str | int] = None, show_region_markers: bool = True, colors: Sequence[str] = None, color_map: Dict[str | int, str] = None, flip_xy: bool = True, **kwargs) plt.Axes

Alias for meshplot().

nanomesh.plotting.trianglemeshplot(mesh: LineMesh | TriangleMesh, ax: plt.Axes = None, key: str = None, legend: str = 'fields', show_labels: Optional[Iterable | str | int] = None, hide_labels: Optional[Iterable | str | int] = None, show_region_markers: bool = True, colors: Sequence[str] = None, color_map: Dict[str | int, str] = None, flip_xy: bool = True, **kwargs) plt.Axes

Alias for meshplot().

nanomesh.plotting.linetrianglemeshplot(mesh: MeshContainer, **kwargs) Tuple[plt.Axes, plt.Axes][source]

Plot line/triangle mesh together.

Parameters
Returns

Tuple of matplotlib axes

Return type

Tuple(matplotlib.axes.Axes, matplotlib.axes.Axes)

nanomesh.plotting.lineplot(ax: Axes, *, x: ndarray, y: ndarray, cells: ndarray, mask: Optional[ndarray] = None, label: Optional[str] = None, **kwargs)[source]

Plot collection of line segments.

API mimicks triplot().

Parameters
Returns

A list of lines representing the line segments and nodes.

Return type

list of matplotlib.lines.Line2D

nanomesh.plotting.pointsplot(mesh: MeshContainer, key: str = None, ax: plt.Axes = None, **kwargs) plt.Axes[source]

Plot mesh points.

Parameters
Return type

matplotlib.axes.Axes