Skip to main content

Publication-quality climate science plotting utilities

Project description

climplot

Publication-quality climate science plotting utilities for Python.

Mission: Help climate science beginners make beautiful, publication-ready plots with minimal effort.

Features

  • Style Modes: Switch between publication and presentation styles with one function call
  • Climate Colormaps: Discrete colormaps optimized for anomaly fields, with center-on-white option
  • Map Utilities: Easy map creation with Cartopy projections
  • Multi-panel Figures: Consistent panel labeling and colorbars
  • Area-weighted Metrics: Accurate statistics for gridded climate data

Installation

pip install climplot

Or install from source:

git clone https://github.com/jkrasting/climplot.git
cd climplot
pip install -e .

Quick Start

import climplot
import matplotlib.pyplot as plt

# Set publication style
climplot.publication()

# Create a map figure
fig, ax = climplot.map_figure()

# Plot with discrete colormap
cmap, norm, levels = climplot.anomaly_cmap(-0.3, 0.3, 0.05)
cs = ax.pcolormesh(lon, lat, data, cmap=cmap, norm=norm, transform=ccrs.PlateCarree())

# Add colorbar
climplot.add_colorbar(cs, ax, 'SSH Anomaly (m)')

# Save
climplot.save_figure('my_figure.png')
plt.close()

Style Modes

Publication Mode

For journal figures with small, dense typography:

  • 3.5" width (single-column), 7.0" (two-column)
  • 8-11pt fonts
  • 300 DPI
climplot.publication()  # Single column
climplot.publication(width=7.0)  # Two-column
climplot.publication(for_pdf=True)  # PDF with embedded fonts

Presentation Mode

For slides and posters with larger, readable typography:

  • 7.0" width
  • 12-16pt fonts
  • 150 DPI
climplot.presentation()
climplot.presentation(for_pdf=True)  # PDF for slides

Colormaps

Anomaly Colormap

Red-blue diverging, centered on zero:

cmap, norm, levels = climplot.anomaly_cmap(-0.3, 0.3, 0.05)

Center-on-White

For difference plots where near-zero values should appear neutral:

cmap, norm, levels = climplot.anomaly_cmap(-0.3, 0.3, 0.05, center_on_white=True)

Maps

# Robinson projection (Pacific-centered)
fig, ax = climplot.map_figure()

# Atlantic-centered
fig, ax = climplot.map_figure(central_longitude=0)

# Different projection
fig, ax = climplot.map_figure(projection='mollweide')

Multi-panel Figures

# 2x3 panel figure
fig, axes = climplot.panel_figure(2, 3)

# Add panel labels (a. b. c. etc.)
climplot.add_panel_labels(axes.flatten())

# Single colorbar below all panels
climplot.bottom_colorbar(cs, fig, axes, 'Temperature (K)')

Area-weighted Metrics

Why area weighting matters: Simple averaging over-weights polar regions. This can produce errors of ~1 cm in global sea level means.

import climplot

# Area-weighted mean (CORRECT)
gmsl = climplot.area_weighted_mean(ssh, areacello, dim=['yh', 'xh'])

# Simple mean (WRONG - ~1 cm error)
# gmsl = ssh.mean(dim=['yh', 'xh'])

# Other metrics
bias = climplot.area_weighted_bias(model, obs, areacello, dim=['yh', 'xh'])
rmse = climplot.area_weighted_rmse(model, obs, areacello, dim=['yh', 'xh'])
corr = climplot.area_weighted_corr(model, obs, areacello, dim=['yh', 'xh'])

# Comprehensive summary
metrics = climplot.metrics_summary(model, obs, areacello, dim=['yh', 'xh'])
climplot.print_metrics_summary(metrics, name='My Model')

Dependencies

  • matplotlib >= 3.7
  • numpy >= 1.24
  • xarray >= 2023.1
  • cartopy >= 0.21

License

MIT License - see LICENSE

Contributing

Contributions are welcome! Please see our contributing guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

climplot-0.2.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

climplot-0.2.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file climplot-0.2.0.tar.gz.

File metadata

  • Download URL: climplot-0.2.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for climplot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6b41709a3d6fe38721bb00c5f740065aa1b6f33d26315b6a2801b3c3684e9a37
MD5 91c12a6fb40d5a6bcfd35bd5c953d0d3
BLAKE2b-256 e46512fb8439ede55c05cfb56db997426c6622de834a4f5c301727ea1852a68a

See more details on using hashes here.

Provenance

The following attestation bundles were made for climplot-0.2.0.tar.gz:

Publisher: publish.yml on jkrasting/climplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file climplot-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: climplot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for climplot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06b8d7fb61d731eb1f6084e13aad55fb4ff40a716041ddfe4ce0520940c43bc1
MD5 244079d2571c599d1d6e0066ff4eb0e8
BLAKE2b-256 16b7270b631b9005f3be3e85b6bc3ce83e0a992faf1a8e725d5a6efebf30b31e

See more details on using hashes here.

Provenance

The following attestation bundles were made for climplot-0.2.0-py3-none-any.whl:

Publisher: publish.yml on jkrasting/climplot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page