Documentation
¶
Overview ¶
Package colors parses colour specifications and maps scalars to colours the way matplotlib does: the same names, the same default property cycle (tab10), and colormaps whose lookup tables are matplotlib's own, generated from it by tools/gen_colormaps.py.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Cycle = []string{
"#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf",
}
Cycle is matplotlib's default property cycle (axes.prop_cycle): the ten Tableau colours, tab:blue first.
Functions ¶
Types ¶
type Colormap ¶
type Colormap struct {
Name string
// Under, Over and Bad are the colours for values below 0, above 1 and
// NaN. Matplotlib's defaults are the first entry, the last entry and
// transparent black; Get sets them so.
Under, Over, Bad RGBA
// contains filtered or unexported fields
}
A Colormap maps [0, 1] to colours through a 256-entry lookup table, as a matplotlib Colormap with N=256 does.
func Get ¶
Get returns the named built-in colormap: viridis, plasma, inferno, magma, cividis, gray, coolwarm or RdBu. A name ending in "_r" returns the map reversed, as in matplotlib.
type LogNorm ¶
type LogNorm struct{ Vmin, Vmax float64 }
LogNorm normalises on a base-10 logarithmic scale. Values <= 0 map to NaN (drawn in the colormap's Bad colour), as matplotlib masks them.
type Normalize ¶
type Normalize struct{ Vmin, Vmax float64 }
Normalize is matplotlib's linear Normalize: (v - Vmin) / (Vmax - Vmin), and 0 when Vmin == Vmax.
type RGBA ¶
type RGBA struct{ R, G, B, A float64 }
RGBA is a colour with straight (not premultiplied) alpha, each component in [0, 1], as matplotlib holds colours.
func CycleColor ¶
CycleColor returns colour i of the default cycle, wrapping around.
func MustParse ¶
MustParse is Parse that panics on an invalid colour, for colours written in source code.
func Parse ¶
Parse reads a colour as matplotlib's to_rgba does: a name ("red", "tab:blue", "C3", "k"), a hex string ("#rgb", "#rgba", "#rrggbb", "#rrggbbaa"), a grey level ("0.5") or "none" (transparent).