Plotting styles and helpers by LamaLab
- Github repository: https://github.com/lamalab-org/lama-aesthetics/
- Documentation https://lamalab-org.github.io/lama-aesthetics/
# Clone the repository
git clone https://github.com/lamalab-org/lama-aesthetics.git
cd lama-aesthetics
# Install with uv (recommended)
uv pip install -e .
# Or install with make (which uses uv)
make installThe library provides two main plotting styles:
- main: Optimized for publications, reports, and other documents.
- presentation: Features larger fonts and thicker lines for better visibility in presentations
import matplotlib.pyplot as plt
import numpy as np
import lama_aesthetics
lama_aesthetics.get_style("main") # or la.get_style("presentation")The package includes several plotting utilities to enhance your visualizations:
- range_frame: Draws a frame around the data range.
- ylabel_top: Places the y-label at the top of the y-axis.
- add_identity: Adds a diagonal reference line.
The package provides predefined figure dimension constants based on common journal column widths and the golden ratio:
from lama_aesthetics import (
ONE_COL_WIDTH,
TWO_COL_WIDTH,
ONE_COL_HEIGHT,
TWO_COL_HEIGHT,
)
# Create a single-column figure with golden ratio proportions
fig, ax = plt.subplots(figsize=(ONE_COL_WIDTH, ONE_COL_HEIGHT))
# Create a two-column figure with golden ratio proportions
fig, ax = plt.subplots(figsize=(TWO_COL_WIDTH, TWO_COL_HEIGHT))Available constants:
ONE_COL_WIDTH: 3 inches (typical single-column width)TWO_COL_WIDTH: 7.25 inches (typical two-column width)ONE_COL_HEIGHT: Single-column height based on golden ratioTWO_COL_HEIGHT: Two-column height based on golden ratio
import matplotlib.pyplot as plt
import numpy as np
from lama_aesthetics.plotutils import range_frame, ylabel_top, add_identity
# Create sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)
# Create a figure
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
# Example 1: Range frame - only shows axes within the data range
axes[0].plot(x, y)
range_frame(axes[0], x, y)
axes[0].set_title("Range Frame")
# Example 2: Top Y-label - places ylabel at top of y-axis
axes[1].plot(x, y)
ylabel_top("sin(x)", axes[1])
axes[1].set_title("Top Y-Label")
# Example 3: Identity line - adds a diagonal reference line
x_scatter = np.linspace(0, 1, 20)
y_scatter = x_scatter + 0.1*np.random.randn(20)
axes[2].scatter(x_scatter, y_scatter)
add_identity(axes[2], linestyle="--", color="gray")
axes[2].set_title("Identity Line")
plt.tight_layout()
plt.show()Repository initiated with lamalab-org/cookiecutter-uv.


