Skip to content

daniisler/Plotting

Repository files navigation

myplots

Minimal plotting utilities for consistently formatted scientific matplotlib figures.

Usage

import myplots as p

p.use_style()
fig, ax = p.new()

Installation

Clone the repository and install in editable mode:

pip install -e .

Quick start

import numpy as np
import myplots as p

# Apply global plotting style
p.use_style(doc_fontsize=10, fig_width="single")

# Generate some data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# Create figure
fig, ax = p.new()

# Plot
p.line(ax, x, y, label="signal")
p.label(ax, rf"{p.bm('x')} axis", rf"{p.bm('y')} axis")
p.legend(ax)

# Save
p.save(fig, "figure.png")

Plotting

p.line(ax, x, y)
p.scatter(ax, x, y)
p.errorbar(ax, x, y, yerr)

Subplots

fig, axs = p.new(nrows=2, ncols=2)

Labels and legends

p.label(ax, "x", "y", "Title")
p.legend(ax)

Subplot annotation

p.annotate_subplots(axs)

Domain specific helpers

p.plot_energy(ax, t, E)
p.plot_temperature(ax, t, T)
p.plot_histogram(ax, data)
p.plot_with_error(ax, x, y, yerr)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages