Skip to content

Plotting

vertax.meshes.plot

Plotting module for meshes.

FacePlot

Bases: Enum

What it is possible to show on a face.

MULTICOLOR class-attribute instance-attribute

MULTICOLOR = 1

Each face get a random color.

FACE_PARAMETER class-attribute instance-attribute

FACE_PARAMETER = 2

The face color depends on its parameter.

AREA class-attribute instance-attribute

AREA = 3

The face color depends on its area.

PERIMETER class-attribute instance-attribute

PERIMETER = 4

The face color depends on its perimeter.

WHITE class-attribute instance-attribute

WHITE = 5

All faces are just white.

FATES class-attribute instance-attribute

FATES = 6

Faces are colored depending on their fate marker (if any).

EdgePlot

Bases: Enum

What it is possible to show on an edge.

BLACK class-attribute instance-attribute

BLACK = 1

All edges are black.

EDGE_PARAMETER class-attribute instance-attribute

EDGE_PARAMETER = 2

The edge color depends on its parameter.

LENGTH class-attribute instance-attribute

LENGTH = 3

The edge color depends on its length.

INVISIBLE class-attribute instance-attribute

INVISIBLE = 4

Do not show edges.

VertexPlot

Bases: Enum

What it is possible to show on a vertex.

BLACK class-attribute instance-attribute

BLACK = 1

Vertices are black.

VERTEX_PARAMETER class-attribute instance-attribute

VERTEX_PARAMETER = 2

The vertex color depends on its parameter.

INVISIBLE class-attribute instance-attribute

INVISIBLE = 3

Do not show vertices.

add_colorbar

add_colorbar(fig: Figure, ax: Axes, v_min: float, v_max: float, cmap: Colormap) -> Colorbar

Add a colorbar to the figure, with given min and max values and colormap.

adjust_lightness

adjust_lightness(color: tuple[float, float, float], amount: float = 0.5) -> tuple[float, float, float]

Adjust lightness of a color.

get_cmap

get_cmap(n: int, name: str = 'hsv') -> Callable[[int], tuple[float, float, float, float]]

Returns a function that maps each index in 0, 1, ..., n-1 to a distinct RGB color.

The keyword argument name must be a standard mpl colormap name.

save_simple_xy_graph

save_simple_xy_graph(filename: str, x_data: list[float], y_data: list[float], title: str = '', x_label: str = '', y_label: str = '') -> None

Save a simple line plot.

plot_mesh

plot_mesh(mesh: Mesh, vertex_plot: VertexPlot = VertexPlot.INVISIBLE, edge_plot: EdgePlot = EdgePlot.BLACK, face_plot: FacePlot = FacePlot.MULTICOLOR, vertex_parameters_name: str = '', edge_parameters_name: str = '', face_parameters_name: str = '', show: bool = False, save: bool = False, save_path: str = 'pbc_mesh.png', faces_cmap_name: str = 'cividis', edges_cmap_name: str = 'coolwarm', edges_width: float = 2, vertices_cmap_name: str = 'spring', vertices_size: float = 20, title: str = '', forced_vertex_scale: tuple[float, float] | None = None, forced_edge_scale: tuple[float, float] | None = None, forced_face_scale: tuple[float, float] | None = None) -> None

Plot the mesh, and return the figure and axes so the caller can save or compose.

Parameters:

Name Type Description Default
show bool

display the figure. Defaults to False. A library function that blocks by default is a defect: under an interactive backend plt.show() waits for a human, which hangs a headless or CI run indefinitely. Pass show=True for an interactive session.

False

Returns:

Type Description
None

(fig, ax). The figure is NOT closed, so it can be saved, annotated or composed; under an inline notebook backend it renders at the end of the cell either way. A caller drawing many meshes should close them itself.

get_plot_mesh

get_plot_mesh(mesh: Mesh, vertex_plot: VertexPlot = VertexPlot.INVISIBLE, edge_plot: EdgePlot = EdgePlot.BLACK, face_plot: FacePlot = FacePlot.MULTICOLOR, vertex_parameters_name: str = '', edge_parameters_name: str = '', face_parameters_name: str = '', faces_cmap_name: str = 'cividis', edges_cmap_name: str = 'coolwarm', edges_width: float = 2, vertices_cmap_name: str = 'spring', vertices_size: float = 20, title: str = '', forced_vertex_scale: tuple[float, float] | None = None, forced_edge_scale: tuple[float, float] | None = None, forced_face_scale: tuple[float, float] | None = None) -> tuple[Figure, Axes]

Get the matplotlib figure and and ax for one plot.