A succinct matplotlib wrapper for making beautiful, publication-quality graphics.
—
Collection of utility functions for color manipulation, unit conversion, array operations, and data processing tasks commonly needed in scientific visualization workflows. Proplot provides numerous helper functions to simplify common plotting tasks.
def arange(min_, *args):
"""
Identical to numpy.arange but with inclusive endpoints.
Parameters:
- min_ (float): Start value
- *args: Stop value and optional step
Returns:
ndarray: Array with inclusive endpoints
"""
def edges(z, axis=-1):
"""
Calculate edge values from center values along an axis.
Parameters:
- z (array): Center values
- axis (int): Axis along which to calculate edges
Returns:
ndarray: Edge values for pcolormesh/contour plotting
"""
def edges2d(z):
"""
Calculate edge values from 2D center values.
Parameters:
- z (array): 2D center values
Returns:
ndarray: 2D edge values
"""def units(value, numeric=None, dest=None, *, fontsize=None, figure=None, axes=None, width=None):
"""
Convert between physical units for plotting dimensions.
Parameters:
- value (unit-spec): Value with unit specification
- numeric (bool): Return numeric value only
- dest (str): Destination unit ('in', 'cm', 'mm', 'pt', 'em')
- fontsize (float): Font size for em/ex units
- figure (Figure): Figure for relative units
- axes (Axes): Axes for relative units
- width (bool): Use width vs height for relative calculations
Returns:
float: Converted value in specified units
"""def get_colors(*args, **kwargs):
"""Get colors from color cycles."""
def set_hue(color, hue, space='hcl'):
"""Set color hue in specified color space."""
def shift_hue(color, shift=0, space='hcl'):
"""Shift color hue by specified amount."""
def scale_luminance(color, scale=1, space='hcl'):
"""Scale color luminance by specified factor."""import proplot as pplt
import numpy as np
# Inclusive arange
levels = pplt.arange(0, 10, 1) # Includes 10
# Edge calculation for pcolormesh
x_centers = np.linspace(0, 10, 11)
y_centers = np.linspace(0, 5, 6)
z = np.random.randn(6, 11)
x_edges = pplt.edges(x_centers)
y_edges = pplt.edges(y_centers)
fig, ax = pplt.subplots()
ax.pcolormesh(x_edges, y_edges, z)
# Unit conversion
width_inches = pplt.units('5cm', dest='in')
fontsize_points = pplt.units('12pt')
# Color manipulation
colors = pplt.get_colors('colorblind', 5)
lighter_red = pplt.scale_luminance('red', 1.2)Install with Tessl CLI
npx tessl i tessl/pypi-proplot