plans.viewer#

Functions designed to handle plots.

Overview#

# todo [major docstring improvement] – overview Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

Example#

# todo [major docstring improvement] – examples Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla mollis tincidunt erat eget iaculis. Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl.

import numpy as np
from plans import viewer

# view sample
uni.view()

Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl.

Functions

build_fig(specs)

Builds a matplotlib figure and GridSpec object based on the given specifications.

get_discrete_cmap(n_classes[, base_cmap_name])

Creates a colormap suitable for plotting classification.

set_colors([style])

Sets the color scheme for the plot, including figure background, axes background, grid, lines, and text.

set_figsize(width_mm, height_mm)

Sets the figure size in millimeters.

set_fonts([style])

Sets the font styles and sizes for plots.

set_frame([style])

Sets the frame style, including ticks, tick labels, axes, and grid.

set_style([style])

Sets the viwer style.

ship_fig(fig[, show, file_output, dpi])

Handles the output of a matplotlib figure, either by showing it or saving it to a file.

plans.viewer.set_figsize(width_mm, height_mm)[source]#

Sets the figure size in millimeters.

Parameters:
  • width_mm (float) – The width of the figure in millimeters.

  • height_mm (float) – The height of the figure in millimeters.

plans.viewer.set_style(style=None)[source]#

Sets the viwer style. options: bare, dark, seaborn, wien, wien-light, wien-clean

Parameters:

style (str) – [optional] The style of the fonts. Default value = “bare”

plans.viewer.set_fonts(style=None)[source]#

Sets the font styles and sizes for plots.

Parameters:

style (str) – [optional] The style of the fonts. Default value = “bare”

plans.viewer.set_frame(style=None)[source]#

Sets the frame style, including ticks, tick labels, axes, and grid.

Parameters:

style (str) – [optional] The style of the frame. Default value = “bare”

plans.viewer.set_colors(style=None)[source]#

Sets the color scheme for the plot, including figure background, axes background, grid, lines, and text.

Parameters:

style (str) – [optional] The color style to apply. Default value = “bare”

plans.viewer.build_fig(specs)[source]#

Builds a matplotlib figure and GridSpec object based on the given specifications.

Parameters:

specs (dict) – A dictionary containing the specifications for the figure and GridSpec. It should include ‘width’, ‘height’, ‘nrows’, ‘ncols’, ‘gs_wspace’, ‘gs_hspace’, ‘gs_left’, ‘gs_right’, ‘gs_bottom’, ‘gs_top’, and optionally ‘style’.

Returns:

A tuple containing the matplotlib figure and GridSpec object.

Return type:

tuple[matplotlib.figure.Figure, matplotlib.gridspec.GridSpec]

plans.viewer.ship_fig(fig, show=True, file_output=None, dpi=300)[source]#

Handles the output of a matplotlib figure, either by showing it or saving it to a file.

Parameters:
  • fig (matplotlib.figure.Figure) – The matplotlib figure to be handled.

  • show (bool) – Whether to display the figure. Default value = True

  • file_output (str) – [optional] The file path to save the figure. If None, the figure is not saved.

  • dpi (int) – The dots per inch for saving the figure. Default value = 300

Returns:

None if show or file_output is true, or the figure object if return_fig is true.

Return type:

matplotlib.figure.Figure or None

plans.viewer.get_discrete_cmap(n_classes, base_cmap_name='viridis')[source]#

Creates a colormap suitable for plotting classification.

Parameters:
  • n_classes (int) – The number of classes.

  • base_cmap_name (str, optional) – The name of the base Matplotlib colormap. Defaults to ‘viridis’.

Returns:

A custom colormap.

Return type:

matplotlib.colors.ListedColormap