Skip to main content

Publication-ready figures for Matplotlib, Seaborn, Plotly, and Altair

Project description

Sane-Figs

Publication-ready figures for Matplotlib, Seaborn, Plotly, and Altair.

Overview

Sane-Figs is a Python package that automatically applies publication-ready styling to figures generated with popular Python visualization libraries. It solves the common problem of figures having text that is too small for articles and presentations.

Features

  • Automatic Styling: Apply publication-ready defaults with a single function call
  • Multiple Libraries: Support for Matplotlib, Seaborn, Plotly, and Altair
  • Version-Aware: Automatically detects library versions and adapts to API changes
  • Two Usage Modes: Global setup or context manager for scoped styling
  • Presets: Built-in presets for articles and presentations
  • Colorways: Publication-ready color palettes (default, nature, vibrant, pastel, colorblind-safe)
  • Watermarks: Text and image watermark support

Installation

pip install sane-figs

For full library support:

pip install sane-figs[all]

Or install with specific libraries:

pip install sane-figs[matplotlib,seaborn]

Quick Start

Global Setup

import sane_figs
import matplotlib.pyplot as plt

# Apply publication defaults globally
sane_figs.setup(mode='article')

# Your existing code works as-is
plt.plot([1, 2, 3], [1, 4, 9])
plt.title('My Figure')
plt.xlabel('X Axis')
plt.ylabel('Y Axis')
plt.savefig('figure.png', dpi=300)

Context Manager

import sane_figs
import matplotlib.pyplot as plt

# Scoped styling
with sane_figs.publication_style(mode='article'):
    plt.plot([1, 2, 3], [1, 4, 9])
    plt.title('My Figure')
    plt.savefig('figure.png')

# Styling resets after context
plt.plot([1, 2, 3], [1, 4, 9])  # Back to default styling

With Colorways

import sane_figs
import matplotlib.pyplot as plt

# Apply colorway
sane_figs.setup(mode='article', colorway='nature')

# List available colorways
print(sane_figs.list_colorways())
# ['default', 'nature', 'vibrant', 'pastel', 'colorblind-safe']

With Watermarks

import sane_figs
import matplotlib.pyplot as plt

# Text watermark
sane_figs.setup(mode='article', watermark='© 2025 My Lab')

# Image watermark
sane_figs.setup(
    mode='article',
    watermark=sane_figs.create_image_watermark('logo.png', opacity=0.2)
)

Presets

Article Mode

Optimized for print publication:

  • Figure size: (6.4, 4.8) inches
  • DPI: 300
  • Title: 14pt
  • Axis labels: 12pt
  • Legend: 10pt
  • Tick labels: 10pt

Presentation Mode

Optimized for slides:

  • Figure size: (10, 7.5) inches
  • DPI: 150
  • Title: 24pt
  • Axis labels: 20pt
  • Legend: 16pt
  • Tick labels: 16pt

Colorways

  • default: Publication-ready palette optimized for print
  • nature: Earth tones inspired by nature
  • vibrant: High contrast colors for presentations
  • pastel: Soft, professional colors
  • colorblind-safe: Designed for colorblind accessibility

API Reference

Main Functions

  • setup(mode='article', libraries=None, colorway=None, watermark=None) - Apply publication defaults globally
  • publication_style(mode='article', libraries=None, colorway=None, watermark=None) - Context manager for scoped styling
  • list_colorways() - List available colorways
  • create_text_watermark(text, **kwargs) - Create a text watermark configuration
  • create_image_watermark(image_path, **kwargs) - Create an image watermark configuration

Per-Library Functions

  • setup_matplotlib(mode='article', colorway=None, watermark=None)
  • setup_seaborn(mode='article', colorway=None, watermark=None)
  • setup_plotly(mode='article', colorway=None, watermark=None)
  • setup_altair(mode='article', colorway=None, watermark=None)

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

sane_figs-0.2.2.tar.gz (51.2 kB view details)

Uploaded Source

Built Distribution

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

sane_figs-0.2.2-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

Details for the file sane_figs-0.2.2.tar.gz.

File metadata

  • Download URL: sane_figs-0.2.2.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sane_figs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1fee1f9526564913c856bdb0f8190f2fff037337b763d4fd7fc3f291c6048a27
MD5 8b6238a0b2f0be6443b0e0ea2f0e1108
BLAKE2b-256 9e3fb5bb4df9ac7ec8ba829d53eaf8e16e87b824e0d95779ec79c2d7d189c12d

See more details on using hashes here.

File details

Details for the file sane_figs-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sane_figs-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 59.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sane_figs-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb159643a564e46e13fc10742fd50dce8dd0d9e017db0506ee8e469d8309a124
MD5 f76dce694cf46a43c358ff1e2ddd458e
BLAKE2b-256 0b872cf1bef955bf3f66ff713d93cbe3b9981d74347ddd8e638c55c89d5f0769

See more details on using hashes here.

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