Matplotlib styling that makes your plots look like MATLAB. Drop-in for AI workflows.
Project description
openlab-style
Matplotlib styling that makes your plots look like MATLAB. Drop-in for AI workflows.
Why
AI assistants (ChatGPT, Claude, Cursor) generate Python + matplotlib for technical computing. But if you're a MATLAB user — a student turning in homework, a researcher collaborating with MATLAB-using labs, an engineer maintaining MATLAB code — matplotlib's output visually screams "not MATLAB." Different colormap. Different fonts. Different line colors. Different axes style.
openlab-style fixes that with a one-liner. Your AI keeps writing Python; your plots come out looking like MATLAB R2014b+.
Install
pip install openlab-style
Use
import openlab_style
openlab_style.apply()
# ... matplotlib code now produces MATLAB-styled output
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(0, 2*np.pi, 200)
plt.plot(t, np.sin(t), t, np.cos(t), t, np.sin(2*t))
plt.legend(['sin(t)', 'cos(t)', 'sin(2t)'])
plt.title('Trig functions')
plt.xlabel('t'); plt.ylabel('amplitude')
plt.grid(True)
plt.show()
That's it. Two lines of setup.
What it looks like
That's matplotlib with openlab_style.apply(grid=True) — same engine your AI is already using, but the output now reads as MATLAB. Lines palette, parula colormap, full axes box, inward ticks, dotted grid, histogram bars with edges, minor ticks on log axes.
Use it in ChatGPT Code Interpreter
ChatGPT Code Interpreter (Advanced Data Analysis) lets you pip install arbitrary packages. So:
Use openlab-style for matplotlib so plots look like MATLAB. Install it first, then plot a damped oscillator from 0 to 10 seconds.
ChatGPT will run:
!pip install openlab-style
import openlab_style; openlab_style.apply(grid=True)
# ...your plot here...
And the resulting figure will look like it came out of MATLAB.
The same trick works in Claude (when given Python execution via MCP, code_execution beta, or a Python sandbox), in Jupyter, in Colab, anywhere pip install runs.
API
openlab_style.apply(*, grid=False, fontsize=10)
Apply MATLAB-style defaults to matplotlib. Mutates global rcParams. Idempotent.
grid: Turn the grid on by default. MATLAB's default isgrid off; many users preferon. DefaultFalse.fontsize: Base font size. MATLAB default is 10pt.
openlab_style.reset()
Reset matplotlib to factory defaults.
openlab_style.MATLAB_LINES
The 7-color MATLAB lines palette as a list of RGB tuples.
openlab_style.MATLAB_LINES_HEX
Same palette as hex strings: ["#0072BD", "#D95319", "#EDB120", "#7E2F8E", "#77AC30", "#4DBEEE", "#A2142F"].
openlab_style.parula_cmap()
Returns MATLAB's parula colormap as a matplotlib ListedColormap. Useful if you want parula without applying the rest of the style:
import matplotlib.pyplot as plt
from openlab_style import parula_cmap
plt.imshow(data, cmap=parula_cmap())
apply() registers parula with matplotlib's global colormap registry, so once called you can also just use cmap='parula' everywhere.
What this doesn't do
- It doesn't make your Python behave like MATLAB (matrix math, indexing, broadcasting differ).
- It doesn't translate MATLAB syntax to NumPy.
- It doesn't run actual MATLAB code.
For those use cases (run real MATLAB code via AI tools, get true MATLAB semantics for bode/tf/eig etc.), see the sister project: openlab — an MCP server that exposes real Octave to Claude, Cursor, and other AI tools.
The two projects are complementary:
| You need... | Use |
|---|---|
| AI's matplotlib plots to look like MATLAB | openlab-style (this package) |
AI to run actual MATLAB code (bode, tf, real Octave semantics) |
openlab (MCP server) |
Compatibility
- Python ≥ 3.9
- matplotlib ≥ 3.5
- Tested with matplotlib 3.10
- No native code, no compilation. Pure Python.
Develop
git clone https://github.com/nxcodeio/openlab-style.git
cd openlab-style
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
python examples/render_demo.py
License
MIT. See LICENSE.
Acknowledgments
- MATLAB's
linespalette andparulacolormap are from MathWorks; the RGB values are public reference data that has been independently reproduced across the open source ecosystem for years. - Inspired by the practical problem of getting AI-generated matplotlib output to fit MATLAB-shaped workflows.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openlab_style-0.1.0.tar.gz.
File metadata
- Download URL: openlab_style-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ec2fc959209ed3217347842d17a0a50402b7b6364acb9c554248259a6c8a7b4
|
|
| MD5 |
127373bce77e239d8d1f6f9dc9e0f725
|
|
| BLAKE2b-256 |
23269dc96f8d4c660433f32209b145380e7e0f006c65fbebafa8b83eb89f249d
|
File details
Details for the file openlab_style-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openlab_style-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18970ef7f25c30ab349fcce87ff248c200674c3d5ee4d4b254efaa33aeee2234
|
|
| MD5 |
7d5e1eab279157574547929bd973619c
|
|
| BLAKE2b-256 |
750fe6a911aa9e02c7f71c5f96fe954e73d5e387147e391a67c23e3eb38241a4
|