Skip to main content

Stylia: decent scientific plot styles

Stylia provides predefined Matplotlib styles, color palettes, and figure utilities for producing publication-quality scientific figures. Designed for the Ersilia Open Source Initiative, but works for any scientific Python project.

Article style (default — NPG palette, black structural elements)

article style demo

Ersilia style (Ersilia brand palette, plum structural elements)

ersilia style demo


Installation

pip install stylia

Importing stylia automatically applies global Matplotlib style settings:

import stylia

Table of Contents


Format and style

stylia.set_format("print")   # default — compact, 7.09 in wide
stylia.set_format("slide")   # larger fonts and markers, 13 in wide

stylia.set_style("article")  # default — structural elements in black
stylia.set_style("ersilia")  # structural elements in Ersilia plum

Both update matplotlib.rcParams globally and can be changed at any point.


Named colors

ArticleColors

Modern palette spanning the full hue wheel for maximum distinctness.

Name Hex
crimson #E63946
tangerine #F4845F
amber #FCBF49
lime #6BBF59
turquoise #2EC4B6
cobalt #457B9D
periwinkle #6C5CE7
orchid #B05CC8
fuchsia #E91E8C
silver #A0A0A0
from stylia import ArticleColors

nc = ArticleColors()
ax.scatter(x, y, color=nc.crimson)
ax.scatter(x, y, color=nc.get("cobalt", alpha=0.4))
ax.scatter(x, y, color=nc.get("turquoise", lighten=0.3))

ErsiliaColors

Official Ersilia brand palette.

Name Hex
plum #50285A
purple #AA96FA
mint #BEE6B4
blue #8CC8FA
yellow #FAD782
pink #DCA0DC
orange #FAA08C
gray #D2D2D0

NamedColors (style-aware)

NamedColors resolves to ArticleColors or ErsiliaColors based on the active style:

nc = stylia.NamedColors()   # ArticleColors or ErsiliaColors depending on set_style()

Continuous colormaps

Four families, each with presets for the article (NPG) and ersilia palettes. All share fit(data) / transform(data, alpha=, lighten=) / sample(n).

FadingColormap

Near-white → single hue. Good for density or strictly positive data.

Article presets (NPG colors)

Preset Range
crimson blush → vivid red (default)
cobalt pale sky → steel blue
turquoise pale mint → teal-cyan
orchid pale lavender → orchid
lime pale green → lime

Ersilia preset

Preset Range
plum pale lilac → deep plum

SpectralColormap

Multi-hue warm → cool. Good for ordered data where the full range matters.

Preset Range
npg (article) crimson → amber → turquoise → periwinkle → fuchsia
ersilia orange → yellow → mint → blue → purple

DivergingColormap

Two hues through a light center. Good for data diverging around a meaningful midpoint.

Article presets (NPG colors)

Preset Range
crimson_cobalt red ↔ steel blue
amber_periwinkle amber ↔ blue-violet

Ersilia presets

Preset Range
plum_mint deep plum ↔ mint
purple_orange lavender ↔ peach

CyclicColormap

Wraps back to its starting color. Good for phase or angle data.

Preset Cycle
npg (article) crimson → tangerine → lime → turquoise → orchid → crimson
ersilia orange → yellow → mint → blue → purple → pink → orange

Usage

from stylia import FadingColormap, DivergingColormap

ccm = FadingColormap("turquoise")
ccm.fit(data)
colors = ccm.transform(data)                 # list of RGBA tuples
colors = ccm.transform(data, alpha=0.6)     # with alpha
colors = ccm.transform(data, lighten=0.3)   # lightened
swatches = ccm.sample(8)                    # 8 evenly-spaced swatches

dcm = DivergingColormap("crimson_cobalt", ascending=False)
dcm.fit(data)
colors = dcm.transform(data)

Categorical palettes

Two built-in palettes match the default styles. Three additional bonus palettes are available for specific needs (colorblind accessibility, soft aesthetics).

from stylia import CategoricalPalette

pal = CategoricalPalette()       # "npg" (default) or "ersilia"

colors = pal.get(5)              # 5 maximally distinguishable colors
colors = pal.get(20)             # >palette size: interpolated as a colormap
color  = pal.next()              # draw one at a time (advances internal counter)

Default palettes

npg — redesigned for maximum hue coverage (article style default)

ersilia — Ersilia brand (ersilia style default)

Bonus palettes

okabe — Okabe–Ito (colorblind-safe)

tol — Paul Tol Bright (colorblind-safe)

pastel — soft pastels


Figures

import stylia

stylia.set_format("print")
stylia.set_style("article")

fig, axs = stylia.create_figure(2, 1, width=0.8, height=0.3)

ax = axs.next()
ax.scatter(x, y, color=nc.crimson, s=stylia.get_markersize())

ax = axs.next()
ax.bar(groups, values, color=pal.get(len(groups)))

stylia.save_figure("figure.pdf")

create_figure accepts width and height as fractions of the format's base size. axs.next() steps through panels in order.


Sizes and constants

All constants resolve automatically to the correct value for the active format — just read stylia.SIZE, stylia.FONTSIZE, etc. after calling set_format(). The explicit SLIDE_* variants are also available if you need to reference both values at once.

width and height in create_figure are fractions of SIZE.

Constant print slide Use
SIZE / SLIDE_SIZE 7.09 in 13 in figure width basis
FONTSIZE_SMALL / SLIDE_FONTSIZE_SMALL 5 pt 8 pt tick labels, annotations
FONTSIZE / SLIDE_FONTSIZE 6 pt 10 pt axis labels, legend
FONTSIZE_BIG / SLIDE_FONTSIZE_BIG 8 pt 13 pt panel titles
MARKERSIZE_SMALL / SLIDE_MARKERSIZE_SMALL 5 8 dense scatter (s=)
MARKERSIZE / SLIDE_MARKERSIZE 10 15 standard scatter (s=)
MARKERSIZE_BIG / SLIDE_MARKERSIZE_BIG 30 45 highlighted points (s=)
LINEWIDTH / SLIDE_LINEWIDTH 0.5 0.75 lines, spines
LINEWIDTH_THICK / SLIDE_LINEWIDTH_THICK 1 1.5 emphasis lines

Use stylia.get_markersize() to get the format-aware marker size at runtime ("small", "normal", or "big").


Tutorial notebook

An end-to-end walkthrough of all stylia features is available in notebooks/stylia_tutorial.ipynb. It covers format and style setup, named colors, all four colormap families, categorical palettes, and figure creation.


Disclaimer

Stylia is designed for internal use across Ersilia projects and is shared openly in case it is useful to others. It is not a general-purpose plotting library — for that, see Matplotlib or seaborn.


About Us

Ersilia logo

Stylia is developed and maintained by the Ersilia Open Source Initiative, a non-profit organisation dedicated to providing open-source AI/ML tools for infectious disease research in the Global South.

Visit us · GitHub

Metadata

Release files for stylia 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stylia 1.0.1
File Size Uploaded Provenance
stylia-1.0.1.tar.gz 1.7 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for stylia 1.0.1
File Interpreter ABI Platform
stylia-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 3.4 MB

Release files / stylia-1.0.1.tar.gz

Download URL stylia-1.0.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
695ca1c9f9c59c2bee6fd8e53ea50827dfa5efb53c1e2e3398f92809e982a11f
BLAKE2b-256 checksum
How to use checksums
8755f442568390981c033f22cef098cd8094d99139fcaf71fe88792b6a597163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1017-azure

Release files / stylia-1.0.1-py3-none-any.whl

Download URL stylia-1.0.1-py3-none-any.whl
Size 1.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
92203eb7768ee878bce76434dba8eb55239b5773bdd0bccf0ca6d1bc80eaf0bd
BLAKE2b-256 checksum
How to use checksums
13faa6d65aaa20d1af86a12add0279787219dcb94fb7a6df3d786f18aa1ad310
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1017-azure

Security for stylia 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page