Skip to main content

Crate prismatica

Crate prismatica 

Source
Expand description

§Prismatica – Scientific Colormaps for Rust

308 scientific colormaps + 70 discrete palettes from 10 collections: matplotlib, Crameri, CET, CMOcean, ColorBrewer, CMasher, NCAR, CartoColors, Moreland, and d3.

use prismatica::crameri::BATLOW;
let color = BATLOW.eval(0.5);
println!("RGB: ({}, {}, {})", color.r, color.g, color.b);

§Feature Flags

FeatureColormapsDescription
core (default)48matplotlib (8) + Crameri (40)
cet+59Peter Kovesi’s perceptually uniform maps
cmocean+22Oceanographic colormaps
colorbrewer+35 (+35 palettes)Cynthia Brewer’s cartographic palettes
cmasher+53Astrophysics colormaps
ncar+44NCAR NCL geoscience maps
cartocolors+34 (+34 palettes)CARTO cartographic maps
moreland+6Cool-warm, black body, Kindlmann
d3+7 (+1 palette)Turbo, Rainbow, Sinebow, Cubehelix, Tableau10
all308 (+70 palettes)Everything

§Framework Integrations

All integrations provide bidirectional conversion via From/Into. Enum-based types (ratatui, crossterm, colored, cursive, comfy-table) use TryFrom for the reverse direction.

FeatureFrameworkType
egui-integrationeguiColor32
plotters-integrationplottersRGBColor
image-integrationimageRgb<u8>
palette-integrationpaletteSrgb<u8>
bevy-color-integrationbevy_colorSrgba
iced-integrationicediced::Color
macroquad-integrationmacroquadmacroquad::Color
tiny-skia-integrationtiny-skiatiny_skia::Color
wgpu-integrationwgpu-typeswgpu_types::Color
slint-integrationslintslint::Color
ratatui-integrationratatuiratatui::Color
crossterm-integrationcrosstermcrossterm::Color
colored-integrationcoloredcolored::Color
owo-colors-integrationowo-colorsowo_colors::Rgb
termion-integrationtermiontermion::color::Rgb
cursive-integrationcursivecursive::Color
comfy-table-integrationcomfy-tablecomfy_table::Color
syntect-integrationsyntectsyntect::Color
serde-supportserdeSerialize/Deserialize
all-integrationsall of the above (except termion, which is Unix-only)

Note: palette-integration, bevy-color-integration, tiny-skia-integration, and slint-integration pull in std via their upstream dependencies and are not compatible with no_std targets.

§Choosing a Colormap

  • Sequential data (temperature, elevation, concentration): batlow, viridis, oslo, thermal
  • Diverging data (anomalies, residuals): berlin, vik, balance, smooth-cool-warm
  • Cyclic data (phase, direction, time-of-day): romaO, phase, twilight
  • Categorical data (labels, classes): SET2, DARK2, PAIRED, Tableau10

§Minimum Supported Rust Version

Prismatica requires Rust 1.85 or later (edition 2024).

Modules§

cartocolorscartocolors
CartoColors cartographic colormaps – 34 colormaps + 34 discrete palettes.
cetcet
CET Perceptually Uniform Colour Maps – 59 colormaps.
cmashercmasher
CMasher colormaps for astrophysics visualization – 53 colormaps.
cmoceancmocean
CMOcean oceanographic colormaps (thermal, haline, solar, ice, deep, and 17 more).
colorbrewercolorbrewer
ColorBrewer palettes (sequential, diverging, and qualitative cartographic schemes).
cramericrameri
Crameri Scientific Colour Maps – 40 colormaps.
d3d3
d3-scale-chromatic colormaps – 7 colormaps + 1 discrete palette (Tableau10).
matplotlibmatplotlib
Matplotlib colormaps (viridis, inferno, magma, plasma, cividis, twilight, mako, rocket).
morelandmoreland
Moreland colormaps (cool-warm, black body, Kindlmann, and variants).
ncarncar
NCAR NCL geoscience colormaps – 44 colormaps.
prelude
Convenience re-exports for common prismatica types.

Structs§

Color
An sRGB color with 8-bit channels.
Colormap
A continuous colormap backed by a precomputed lookup table.
ColormapMeta
Metadata about a colormap’s scientific properties.
ConversionError
Error returned when a framework color cannot be converted to Color.
DiscretePalette
A discrete palette of distinct colors for categorical data.
ParseColorError
Error returned when parsing a Color from a string fails.
ReversedColormap
A reversed view of a colormap. Zero allocation.

Enums§

ColormapKind
The type/class of a colormap, following standard scientific nomenclature.

Traits§

IntoFrameworkColor
Trait for converting a prismatica Color to a framework-specific color type.

Functions§

all_colormapsalloc or std
Returns all colormaps enabled by the current feature flags.
all_discrete_palettesalloc or std
Returns all discrete palettes enabled by the current feature flags.
filter_by_collectionalloc or std
Return all colormaps from a given collection.
filter_by_kindalloc or std
Return all colormaps of a given kind.
find_by_name
Look up a colormap by its canonical name (case-sensitive).
find_palette_by_name
Look up a discrete palette by its canonical name (case-sensitive).