Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ cython_debug/

# Figures and videos
figures/
*.png
#*.png
*.pdf
*.jpg
*.jpeg
Expand All @@ -188,4 +188,4 @@ figures/
env*

# VS code
.vscode/*
.vscode/*
80 changes: 69 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,85 @@
# maxplotlib
# Maxlotlib

This is a wrapper for matplotlib so I can produce figures with consistent formatting. It also has some pretty nice additions such as using layers and exporting to tikz.

# Maxplotlib

A clean, expressive wrapper around **Matplotlib** **tikzfigure** for
producing publication-quality figures with minimal boilerplate. Swap
backends without rewriting your data — render the same canvas as a crisp
PNG, an interactive Plotly chart, or camera-ready **TikZ** code for
LaTeX.

## Install

Create and activate python environment
``` bash
pip install maxplotlibx
```

## Showcase

### Quickstart

``` python
import numpy as np
from maxplotlib import Canvas

x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)

canvas, ax = Canvas.subplots()
ax.plot(x, y)
```
python -m venv env
source env/bin/activate
pip install --upgrade pip

Plot the figure with the default (matplotlib) backend:

``` python
canvas.show()
```

Install the code and requirements with pip
![](README_files/figure-markdown_strict/cell-3-output-1.png)

Alternatively, plot with the TikZ backend (not done yet):

``` python
canvas.show(backend="tikzfigure")
```
pip install -e .

![](README_files/figure-markdown_strict/cell-4-output-1.png)

### Layers

``` python
x = np.linspace(0, 2 * np.pi, 200)

canvas, ax = Canvas.subplots(width="10cm", ratio=0.55)

ax.plot(x, np.sin(x), color="steelblue", label=r"$\sin(x)$", layer=0)
ax.plot(x, np.cos(x), color="tomato", label=r"$\cos(x)$", layer=1)
ax.plot(
x,
np.sin(x) * np.cos(x),
color="seagreen",
label=r"$\sin(x)\cos(x)$",
linestyle="dashed",
layer=2,
)

ax.set_xlabel("x")
ax.set_legend(True)
```

Additional dependencies for developers can be installed with
Show layer 0 only, then layers 0 and 1, then everything:

``` python
canvas.show(layers=[0])
```
pip install -e ".[dev]"

![](README_files/figure-markdown_strict/cell-6-output-1.png)

Show all layers:

``` python
canvas.show()
```

Some examples can be found in `tutorials/`
![](README_files/figure-markdown_strict/cell-7-output-1.png)
86 changes: 86 additions & 0 deletions README.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: Maxlotlib
format: gfm
fig-dpi: 150
---

# Maxplotlib

A clean, expressive wrapper around **Matplotlib** **tikzfigure** for producing publication-quality figures
with minimal boilerplate. Swap backends without rewriting your data — render the same canvas
as a crisp PNG, an interactive Plotly chart, or camera-ready **TikZ** code for LaTeX.

## Install

```bash
pip install maxplotlibx
```

## Showcase

### Quickstart

```{python}
#| label: fig-showcase-1
#| fig-width: 9
#| fig-height: 6

import numpy as np
from maxplotlib import Canvas

x = np.linspace(0, 2 * np.pi, 200)
y = np.sin(x)

canvas, ax = Canvas.subplots()
ax.plot(x, y)
```

Plot the figure with the default (matplotlib) backend:

```{python}
canvas.show()
```

Alternatively, plot with the TikZ backend (not done yet):

```{python}
canvas.show(backend="tikzfigure")
```

### Layers

```{python}
#| label: fig-showcase-2
#| fig-width: 9
#| fig-height: 6

x = np.linspace(0, 2 * np.pi, 200)

canvas, ax = Canvas.subplots(width="10cm", ratio=0.55)

ax.plot(x, np.sin(x), color="steelblue", label=r"$\sin(x)$", layer=0)
ax.plot(x, np.cos(x), color="tomato", label=r"$\cos(x)$", layer=1)
ax.plot(
x,
np.sin(x) * np.cos(x),
color="seagreen",
label=r"$\sin(x)\cos(x)$",
linestyle="dashed",
layer=2,
)

ax.set_xlabel("x")
ax.set_legend(True)
```

Show layer 0 only, then layers 0 and 1, then everything:

```{python}
canvas.show(layers=[0])
```

Show all layers:

```{python}
canvas.show()
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading