mathxlab.plots.helpers

Matplotlib styling and layout helpers.

Stability

Status: Experimental.

This project treats the documented names as the public surface, but details may still evolve. If you need strict API guarantees, add __all__ = [...] to each module and version releases accordingly.

Design notes

  • Keep figure styling consistent across experiments.

  • Prefer small helpers over copy/pasted plotting code.

Examples

Finalize a Matplotlib figure

import matplotlib.pyplot as plt
from mathxlab.plots.helpers import finalize_figure
finalize_figure(plt.figure())

Public API

Name

Kind

Summary

apply_axis_style

function

Apply common axis styling.

configure_mathtext

function

Configure Matplotlib MathText to look more LaTeX-like.

finalize_figure

function

Finalize a Matplotlib figure (layout + MathText config).

Reference

Functions

mathxlab.plots.helpers.apply_axis_style(ax, *, title, xlab, ylab, equal=False)[source]

Apply common axis styling.

Parameters:
  • ax – Matplotlib axes to style.

  • title – Plot title.

  • xlab – X-axis label.

  • ylab – Y-axis label.

  • equal – If True, enforce equal scaling (useful for geometry-like plots).

Examples

>>> from mathxlab.plots.helpers import apply_axis_style
>>> apply_axis_style
mathxlab.plots.helpers.configure_mathtext()[source]

Configure Matplotlib MathText to look more LaTeX-like.

This repository uses MathText (not a full TeX installation) for portability. The settings here make $…$ labels and titles render closer to LaTeX.

Notes

These settings are global (rcParams).

Examples

>>> from mathxlab.plots.helpers import configure_mathtext
>>> configure_mathtext
mathxlab.plots.helpers.finalize_figure(fig)[source]

Finalize a Matplotlib figure (layout + MathText config).

Parameters:

fig – The figure to finalize.

Examples

>>> import matplotlib.pyplot as plt
>>> from mathxlab.plots.helpers import finalize_figure
>>> fig = plt.figure(); finalize_figure(fig)