Skip to main content

Acceptable figure styles for scientific publications

Project description

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

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

stylia-1.0.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

stylia-1.0.1-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file stylia-1.0.1.tar.gz.

File metadata

  • Download URL: stylia-1.0.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1017-azure

File hashes

Hashes for stylia-1.0.1.tar.gz
Algorithm Hash digest
SHA256 695ca1c9f9c59c2bee6fd8e53ea50827dfa5efb53c1e2e3398f92809e982a11f
MD5 b6d4ca89f4c704b749e5c202319a37ef
BLAKE2b-256 8755f442568390981c033f22cef098cd8094d99139fcaf71fe88792b6a597163

See more details on using hashes here.

File details

Details for the file stylia-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: stylia-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.14.0-1017-azure

File hashes

Hashes for stylia-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92203eb7768ee878bce76434dba8eb55239b5773bdd0bccf0ca6d1bc80eaf0bd
MD5 8c17be01aea90e214e5a8399a29d7b1a
BLAKE2b-256 13faa6d65aaa20d1af86a12add0279787219dcb94fb7a6df3d786f18aa1ad310

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