fabricatio_plot.toolboxes.plot

Module for creating and customizing plots using matplotlib.

This module provides a toolbox with various functions to create figures, add different types of plots, customize plot appearance, and save or display plots. It is built on top of matplotlib and offers a simplified interface for common plotting tasks.

Attributes

plot_toolbox

Functions

create_figure(, dpi)

Create a new matplotlib figure.

create_subplots() → Tuple[matplotlib.figure.Figure, ...)

Create a figure and grid of subplots.

plot_line(→ None)

Plot a line chart on specified axes.

plot_bar(→ None)

Plot a vertical bar chart.

plot_scatter(→ None)

Create a scatter plot.

set_labels(→ None)

Set axis labels and chart title.

set_legend(→ None)

Add legend to the chart.

configure_grid(→ None)

Configure grid lines on the chart.

save_plot(→ None)

Save figure to file.

Module Contents

fabricatio_plot.toolboxes.plot.plot_toolbox
fabricatio_plot.toolboxes.plot.create_figure(figsize: Tuple[float, float] = (8, 6), dpi: int = 200) matplotlib.figure.Figure

Create a new matplotlib figure.

Parameters:
  • figsize – Width and height of the figure in inches (default: (8, 6)).

  • dpi – Dots per inch resolution (default: 200).

Returns:

Newly created Figure object.

fabricatio_plot.toolboxes.plot.create_subplots(nrows: int = 1, ncols: int = 1, figsize: Tuple[float, float] = (8, 6)) Tuple[matplotlib.figure.Figure, numpy.ndarray]

Create a figure and grid of subplots.

Parameters:
  • nrows – Number of rows in subplot grid.

  • ncols – Number of columns in subplot grid.

  • figsize – Width and height of the figure in inches.

Returns:

  • Figure object

  • Numpy array of Axes objects

Return type:

Tuple containing

fabricatio_plot.toolboxes.plot.plot_line(ax: matplotlib.axes.Axes, x: List[float], y: List[float], label: str | None = None, color: str = 'blue', linewidth: float = 2.0, linestyle: str = '-') None

Plot a line chart on specified axes.

Parameters:
  • ax – Target axes object.

  • x – X-axis data points.

  • y – Y-axis data points.

  • label – Legend label for the line.

  • color – Line color (default: ‘blue’).

  • linewidth – Line width in points (default: 2.0).

  • linestyle – Line style (e.g., ‘-’, ‘–’, ‘:’, ‘-.’).

fabricatio_plot.toolboxes.plot.plot_bar(ax: matplotlib.axes.Axes, categories: List[str], values: List[float], color: str = 'skyblue', width: float = 0.8) None

Plot a vertical bar chart.

Parameters:
  • ax – Target axes object.

  • categories – Category labels for each bar.

  • values – Height values for each bar.

  • color – Bar fill color (default: ‘skyblue’).

  • width – Bar width (default: 0.8).

fabricatio_plot.toolboxes.plot.plot_scatter(ax: matplotlib.axes.Axes, x: List[float], y: List[float], color: str = 'red', size: float = 20, marker: str = 'o', alpha: float = 0.7) None

Create a scatter plot.

Parameters:
  • ax – Target axes object.

  • x – X-coordinates of points.

  • y – Y-coordinates of points.

  • color – Point color (default: ‘red’).

  • size – Marker size in points (default: 20).

  • marker – Marker style (e.g., ‘o’, ‘s’, ‘^’).

  • alpha – Opacity (0=transparent, 1=opaque, default: 0.7).

fabricatio_plot.toolboxes.plot.set_labels(ax: matplotlib.axes.Axes, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None) None

Set axis labels and chart title.

Parameters:
  • ax – Target axes object.

  • title – Chart title text.

  • xlabel – X-axis label text.

  • ylabel – Y-axis label text.

fabricatio_plot.toolboxes.plot.set_legend(ax: matplotlib.axes.Axes, location: str = 'best', fontsize: int = 10) None

Add legend to the chart.

Parameters:
  • ax – Target axes object.

  • location – Legend position (e.g., ‘upper right’, ‘lower left’).

  • fontsize – Legend text size (default: 10).

fabricatio_plot.toolboxes.plot.configure_grid(ax: matplotlib.axes.Axes, visible: bool = True, linestyle: str = '--', alpha: float = 0.5) None

Configure grid lines on the chart.

Parameters:
  • ax – Target axes object.

  • visible – Toggle grid visibility (default: True).

  • linestyle – Grid line style (default: ‘–‘).

  • alpha – Grid opacity (0-1, default: 0.5).

fabricatio_plot.toolboxes.plot.save_plot(fig: matplotlib.figure.Figure, save_path: str | pathlib.Path, dpi: int = 300, transparent: bool = False) None

Save figure to file.

Parameters:
  • fig – Figure object to save.

  • save_path – Output path (include extension: .png, .jpg, .pdf).

  • dpi – Output resolution (default: 300).

  • transparent – Save with transparent background (default: False).