Skip to main content

my-mpl-style

PyPI Python versions License: MIT

Two small helpers that give matplotlib figures a publication-ready look: plot_rc() sets a consistent rcParams preset (serif fonts, Computer Modern math, a MATLAB-like colour cycle, optional grid and inward ticks), and ax_setting3D() turns a 3D axes into a clean orthographic box.

Installation

pip install my-mpl-style

Requires Python 3.10+ and matplotlib 3.5+.

Quick start

import matplotlib.pyplot as plt
from my_mpl_style import plot_rc

plot_rc(grid=True)

fig, ax = plt.subplots()
ax.plot([0, 1, 2], [0, 1, 4], label="data")
ax.set(xlabel="$x$", ylabel="$y$")
ax.legend(frameon=False)
plt.show()

3D axes

import matplotlib.pyplot as plt
import numpy as np
from my_mpl_style import ax_setting3D

a = np.linspace(-1, 1, 200)
x, y = np.meshgrid(a, a)
z = np.sin(np.pi * x) * np.exp(y)

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
ax.plot_surface(x, y, z, linewidth=0, antialiased=True)
ax_setting3D(ax, (-1, 1), (-1, 1), (z.min(), z.max()), box_aspect=(1, 1, 1))
plt.show()

API

plot_rc(grid=False, tick_direction="out", tick_right=False, tick_top=False)

Updates the global matplotlib.rcParams, so it affects every figure created afterwards.

Parameter Type Default Description
grid bool False Draw light major grid lines behind the artists.
tick_direction "in" | "out" "out" Direction of the tick marks.
tick_right bool False Also show ticks and labels on the right y axis.
tick_top bool False Also show ticks and labels on the top x axis.

ax_setting3D(ax, xlim, ylim, zlim, aspect="equal", box_aspect=None, xticks_pad=-5, yticks_pad=-5, zticks_pad=0)

Makes the panes transparent, thins the grid and tick marks, aligns the tick labels next to their axes, and draws the grey back edge of the box.

Parameter Type Default Description
ax Axes (3D) — A 3D axes created with projection="3d".
xlim, ylim, zlim Sequence[float] — Axis limits.
aspect "auto" | "equal" "equal" Data aspect.
box_aspect Sequence[float] | None None Ratio of the axes box along x, y and z.
*_pad float -5, -5, 0 Padding between axis and tick labels (pt).

Development

python -m venv .venv
.venv\Scripts\activate          # Windows
pip install -e ".[dev]"

pytest
python examples/demo.py          # regenerate docs/images/demo.png
python -m build
twine check dist/*

License

MIT © 2026 chengtau

Metadata

Release files for my-mpl-style 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for my-mpl-style 0.1.0
File Size Uploaded Provenance
my_mpl_style-0.1.0.tar.gz 240.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for my-mpl-style 0.1.0
File Interpreter ABI Platform
my_mpl_style-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 246.9 kB

Release files / my_mpl_style-0.1.0.tar.gz

Download URL my_mpl_style-0.1.0.tar.gz
Size 240.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e377195968228cc75a0f242cfce4baab9860172a93a6e3417519e6d5b5a1d209
BLAKE2b-256 checksum
How to use checksums
5194fda8575058664c3c84c104cecce130fe8260bd24dffea929f1f265ba38ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / my_mpl_style-0.1.0-py3-none-any.whl

Download URL my_mpl_style-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bcaf1f1e9402cebe27c2cdb408e1a485ed5a8f01b98ccdd1103fadae3860569
BLAKE2b-256 checksum
How to use checksums
aefc55c52a004811081686e3354bb14e821f62191226dc3d06a71e6abe0d0de1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for my-mpl-style 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page