ragraph.colors
#
Colors and palettes for RaGraph plots.
This module contains several convenient methods to obtain color palettes as lists of
hex-coded colors. The defaults for categorical and continuous data are
get_categorical
and get_continuous
, respectively.
Additional methods are included, most of which are based on the
cubehelix
palette with certain preset options.
get_hue
is a great way to get a sequential color palette for any hue where the
hue value corresponds to anything between red (1.0), green (2.0) or blue (3.0).
In our plots, these colors are not interpolated. This opens up an easy way to visualize your colors in a discrete fashion, since you merely need to supply a list with less colors (e.g. the desired number of discrete steps).
Submodules#
Package Contents#
Functions#
|
Calculate a cubehelix color palette as a list of hex codes. |
|
Get a color palette suitable for categorical data. |
|
Get a default color palette suitable for continuous valued data. |
|
Get a sequential color palette with the given hue. |
|
Get a purple sequential color palette. |
|
Get a red sequential color palette. |
|
Get an orange sequential color palette. |
|
Get a green sequential color palette. |
|
Get a cyan sequential color palette. |
|
Get a blue sequential color palette. |
|
Get a diverging color palette between two hues. |
|
Get a red-white-blue diverging color palette. |
|
Get a orange-white-cyan diverging color palette. |
|
Get a purple-white-green diverging color palette. |
|
Get multiple colormaps of a certain kind. |
- ragraph.colors.cubehelix_palette(n_colors: int, start: float = 2.25, end: float = 3.45, dark: float = 0.2, light: float = 0.85, gamma: float = 1.0, saturation: float = 1.2, rotations: Optional[float] = None, categorical: bool = False) List[str] #
Calculate a cubehelix color palette as a list of hex codes.
- Parameters:
n_colors – Number of RGB colour pairs to generate.
start – Starting color (Red: 1.0, Green: 2.0, Blue: 3.0).
end – Final color (Red: 1.0, Green: 2.0, Blue: 3.0).
dark – Lightness of the darkest value [0.0 - 1.0].
light – Lightness of the lightest value [0.0 - 1.0].
gamma – Exponential factor applied to lightness to emphasize low intensity values (< 1.0) or high intensity values (> 1.0).
rotations – Number of RGB rotations (1.0 means a full RGB rotation). Overrides
end
. Otherwise calculated as (end - start) / 3.categorical – Whether to shuffle the rotational space optimally for categorical color palettes. Similar colors are positioned as far apart as possible.
- Returns:
Color palette as a list of hex codes.
- Reference:
Green, D. A. (2011). A colour scheme for the display of astronomical intensity images. Bull. Astr. Soc. India. Retrieved from http://www.astro.caltech.edu/
- ragraph.colors.get_categorical(n_colors: int = 10, **kwargs) List[str] #
Get a color palette suitable for categorical data.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_continuous(n_colors: int = 256, **kwargs) List[str] #
Get a default color palette suitable for continuous valued data.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_hue(n_colors: int = 256, hue: float = 1.0, **kwargs) List[str] #
Get a sequential color palette with the given hue.
- Parameters:
n_colors – Number of colors to generate.
hue – Hue for this sequential color palette.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_purple(n_colors: int = 256, **kwargs) List[str] #
Get a purple sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_red(n_colors: int = 256, **kwargs) List[str] #
Get a red sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_orange(n_colors: int = 256, **kwargs) List[str] #
Get an orange sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_green(n_colors: int = 256, **kwargs) List[str] #
Get a green sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_cyan(n_colors: int = 256, **kwargs) List[str] #
Get a cyan sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_blue(n_colors: int = 256, **kwargs) List[str] #
Get a blue sequential color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_diverging_hues(n_colors: int = 257, lower_hue: float = 0.95, upper_hue: float = 2.85, midpoint: float = 0.5, **kwargs) List[str] #
Get a diverging color palette between two hues.
- Parameters:
n_colors – Number of colors (will always return an uneven number of colors).
lower_hue – Lower bound hue value.
upper_hue – Upper bound hue value.
midpoint – Fraction between [0.0, 1.0] where to put the midpoint.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_diverging_redblue(n_colors: int = 257, **kwargs) List[str] #
Get a red-white-blue diverging color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_diverging_orangecyan(n_colors: int = 257, **kwargs) List[str] #
Get a orange-white-cyan diverging color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_diverging_purplegreen(n_colors: int = 257, **kwargs) List[str] #
Get a purple-white-green diverging color palette.
- Parameters:
n_colors – Number of colors to generate.
- Returns:
A list of colors as hex codes.
Note
Additional keyword arguments are passed on to
ragraph.colors.cubehelix.cubehelix_palette
.
- ragraph.colors.get_colormaps(n_colors: int = 1, kind: str = 'categorical', amount: int = 1, flip: bool = False) List[List[str]] #
Get multiple colormaps of a certain kind.
- Parameters:
n_colors – Number of colors per colormap to generate.
kind – Kind of colormap. One of ‘categorical’, ‘sequential’, or ‘diverging’.
amount – Number of colormaps to generate.
flip – Whether to reverse the generated colormaps.