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
inpyproject.toml
or$MINDLAB_APPLY_MINDLAB_STYLES
.project_styles – The project styles to use in addition to the MindLab style. Defaults to
tool.mindlab.styles
inpyproject.toml
or$MINDLAB_STYLES
.
- Returns:
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
orday
). Defaults toeng
inlinear
scale andlog
inlog
scale.ytics – The y tick locators (same choices as for xtics).
xscale – The scale of the x axis (one of
linear
orlog
).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 oftop
/center
/bottom
andleft
/center
/right
.
- figure
The underlying figure instance.
- Type:
- axes
The underlying axes instance.
- Type:
- save(output: str | PathLike[Any] | IO[Any], **kwargs: Any) None
Save the figure.
- Parameters:
output – A path or object to use for saving.
**kwargs – Arguments to forward to
matplotlib.figure.Figure.savefig()
.
- line(*args: Any, **kwargs: Any) None
Draw a line chart.
- Parameters:
*args – Arguments to forward to
matplotlib.axes.Axes.plot()
. If the first argument is a grouped data frame (see GroupBy) we draw a line for each group.**kwargs – Arguments to forward to
matplotlib.axes.Axes.plot()
.
- scatter(*args: Any, **kwargs: Any) None
Draw a scatter plot.
- Parameters:
*args – Arguments to forward to
matplotlib.axes.Axes.scatter()
. If the first argument is a grouped data frame (see GroupBy) we draw a scatter plot for each group.**kwargs – Arguments to forward to
matplotlib.axes.Axes.scatter()
.
- bar(data: DataFrameGroupBy, **kwargs: Any) None
Draw a stacked bar chart.
- Parameters:
data – The grouped data frame to plot (see GroupBy).
**kwargs – Arguments to forward to
matplotlib.axes.Axes.bar()
.