plot::colormap
Colormaps: 256-entry lookup tables, as matplotlib builds them, from the published data (tables.nabi) or from control colours.
Structs
ColormapSource
pub struct ColormapA map from [0, 1] to colours: 256 entries, looked up as matplotlib
does (v in [k / 256, (k + 1) / 256) gives entry k). NaN gives
bad, values below 0 under and above 1 over, which default to
transparent, the first entry and the last.
use plot::{Color, Colormap};
let m = Colormap::viridis();
assert(m.at(0.0) == Color::rgb(68, 1, 84));
assert(m.at(1.0) == Color::rgb(253, 231, 37));
assert(m.at(f64::NAN).a == 0);
The name,
"viridis"or"custom"; reversed maps end in_r.The 256 entries.
The colour for NaN.
The colour below 0.
The colour above 1.
Perceptually uniform, blue to yellow (van der Walt and Smith, 2015); the default.
nabiassert(plot::Colormap::viridis().name == "viridis");Perceptually uniform, black to light pink.
nabiassert(plot::Colormap::magma().at(0.0) == plot::Color::rgb(0, 0, 4));Perceptually uniform, black to light yellow.
nabiassert(plot::Colormap::inferno().at(1.0) == plot::Color::rgb(252, 255, 164));Perceptually uniform, blue to yellow through magenta.
nabiassert(plot::Colormap::plasma().at(0.0) == plot::Color::rgb(13, 8, 135));Viridis adjusted for colour-vision deficiency (Nunez, Anderton and Renslow, 2018).
nabiassert(plot::Colormap::cividis().at(1.0) == plot::Color::rgb(254, 232, 56));Moreland's diverging blue-white-red map (2009), for data around a centre.
nabiassert(plot::Colormap::coolwarm().at(0.0) == plot::Color::rgb(59, 76, 192));Black to white.
nabiassert(plot::Colormap::gray().at(0.5) == plot::Color::rgb(128, 128, 128));The map named
name("viridis","magma","inferno","plasma","cividis","coolwarm","gray"), reversed with a_rsuffix;nonefor another name.nabiuse plot::Colormap; assert((Colormap::named("magma_r") ?? Colormap::gray()).at(0.0) == Colormap::magma().at(1.0));Evenly spaced control colours joined linearly.
nabiuse plot::{Color, Colormap}; let m = Colormap::from_colors([Color::rgb(0, 0, 0), Color::rgb(255, 0, 0)]); assert(m.at(1.0) == Color::rgb(255, 0, 0));The colour for
vin [0, 1].nabiassert(plot::Colormap::gray().at(2.0) == plot::Color::rgb(255, 255, 255));The map run backwards.
nabiassert(plot::Colormap::gray().reversed().at(0.0) == plot::Color::rgb(255, 255, 255));