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 or by using the mindlab.use_mindlab_styles() function.

mindlab.use_mindlab_styles(style_install_path: Optional[Path] = None, font_install_path: Optional[Path] = None, project_styles: Optional[Union[bool, Iterable[str]]] = None) bool

Install and use MindLab and project styles.

Parameters
  • style_install_path – The path to install the MindLab styles to. Defaults to the Matplotlib package style library directory.

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

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

Returns

True if the styles were applied and False otherwise.

Reference

class mindlab.Figure(size: Optional[Tuple[float, float]] = None, title: Optional[str] = None, xlabel: Optional[str] = None, ylabel: Optional[str] = None, xtics: Optional[str] = None, ytics: Optional[str] = None, xscale: Optional[str] = None, yscale: Optional[str] = None, xlim: Optional[Tuple[Optional[float], Optional[float]]] = None, ylim: Optional[Tuple[Optional[float], Optional[float]]] = None, legend: Optional[str] = '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: Union[Path, IOBase], **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().