Plotting

Style

You can apply your own custom plotting styles in addition to the MindLab default style via the tool.mindlab.styles list in pyproject.toml, via the MINDLAB_STYLES environment variable or by using the mindlab.use_mindlab_styles() function.

mindlab.use_mindlab_styles(font_install_path: Path | None = None, apply_mindlab_styles: bool = True, project_styles: bool | Iterable[str] | None = None) bool

Install and use MindLab and project styles.

Parameters:
  • font_install_path – The path to install the style fonts to. Defaults to $XDG_DATA_HOME/fonts.

  • apply_mindlab_styles – Whether to use the MindLab styles. Defaults to tool.mindlab.apply_mindlab_styles in pyproject.toml or $MINDLAB_APPLY_MINDLAB_STYLES.

  • project_styles – The project styles to use in addition to the MindLab style. Defaults to tool.mindlab.styles in pyproject.toml or $MINDLAB_STYLES.

Returns:

True if the styles were applied and False otherwise.

Reference

class mindlab.Figure(*, size: tuple[float, float] | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, xtics: str | None = None, ytics: str | None = None, xscale: str | None = None, yscale: str | None = None, xlim: tuple[float | None, float | None] | None = None, ylim: tuple[float | None, float | None] | None = None, legend: str | None = 'best')

Create professional plots easily.

Note that in addition to the overwritten methods described below, a Figure instance also exposes all the same methods as the underlying matplotlib.axes.Axes instance.

Parameters:
  • size – The size of the figure (in inches).

  • title – The title of the figure.

  • xlabel – The x axis label of the figure.

  • ylabel – The y axis label of the figure.

  • xtics – The x tick locators (one of eng, auto, log, percent, year, month, week or day). Defaults to eng in linear scale and log in log scale.

  • ytics – The y tick locators (same choices as for xtics).

  • xscale – The scale of the x axis (one of linear or log).

  • yscale – The scale of the y axis (same choices as for xscale).

  • xlim – The x axis limits.

  • ylim – The y axis limits.

  • legend – The location of the legend (either best, or a combination of top/center/bottom and left/center/right.

figure

The underlying figure instance.

Type:

matplotlib.figure.Figure

axes

The underlying axes instance.

Type:

matplotlib.axes.Axes

save(output: str | PathLike[Any] | IO[Any], **kwargs: Any) None

Save the figure.

Parameters:
line(*args: Any, **kwargs: Any) None

Draw a line chart.

Parameters:
scatter(*args: Any, **kwargs: Any) None

Draw a scatter plot.

Parameters:
bar(data: DataFrameGroupBy, **kwargs: Any) None

Draw a stacked bar chart.

Parameters:
kde(series: Series, rug: bool = True, **kwargs: Any) None

Draw a kernel density estimation plot.

Parameters:
  • series – The series for which to calculate the kernel density estimate.

  • rug – Whether to add a rug plot.

  • **kwargs – Arguments to forward to pandas.Series.plot().