ragraph.colors
¶
RaGraph colors and palettes¶
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).
get_blue
¶
Get a blue sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_categorical
¶
Get a color palette suitable for categorical data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
10
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_colormaps
¶
Get multiple colormaps of a certain kind.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors per colormap to generate. |
1
|
kind |
str
|
Kind of colormap. One of 'categorical', 'sequential', or 'diverging'. |
'categorical'
|
amount |
int
|
Number of colormaps to generate. |
1
|
flip |
bool
|
Whether to reverse the generated colormaps. |
False
|
Source code in ragraph/colors/__init__.py
get_continuous
¶
Get a default color palette suitable for continuous valued data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_cyan
¶
Get a cyan sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_diverging_hues
¶
Get a diverging color palette between two hues.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors (will always return an uneven number of colors). |
257
|
lower_hue |
float
|
Lower bound hue value. |
0.95
|
upper_hue |
float
|
Upper bound hue value. |
2.85
|
midpoint |
float
|
Fraction between [0.0, 1.0] where to put the midpoint. |
0.5
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_diverging_orangecyan
¶
Get a orange-white-cyan diverging color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
257
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_diverging_purplegreen
¶
Get a purple-white-green diverging color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
257
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_diverging_redblue
¶
Get a red-white-blue diverging color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
257
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_green
¶
Get a green sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_hue
¶
Get a sequential color palette with the given hue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
hue |
float
|
Hue for this sequential color palette. |
1.0
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_orange
¶
Get an orange sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_purple
¶
Get a purple sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
get_red
¶
Get a red sequential color palette.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of colors to generate. |
256
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of colors as hex codes. |
Note
Additional keyword arguments are passed on to
cubehelix_palette
.
Source code in ragraph/colors/__init__.py
cubehelix
¶
Cubehelix color palette¶
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/.
cubehelix_palette
¶
Calculate a cubehelix color palette as a list of hex codes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_colors |
int
|
Number of RGB colour pairs to generate. |
required |
start |
float
|
Starting color (Red: 1.0, Green: 2.0, Blue: 3.0). |
2.25
|
end |
float
|
Final color (Red: 1.0, Green: 2.0, Blue: 3.0). |
3.45
|
dark |
float
|
Lightness of the darkest value [0.0 - 1.0]. |
0.2
|
light |
float
|
Lightness of the lightest value [0.0 - 1.0]. |
0.85
|
gamma |
float
|
Exponential factor applied to lightness to emphasize low intensity values (< 1.0) or high intensity values (> 1.0). |
1.0
|
rotations |
Optional[float]
|
Number of RGB rotations (1.0 means a full RGB rotation). Overrides |
None
|
categorical |
bool
|
Whether to shuffle the rotational space optimally for categorical color palettes. Similar colors are positioned as far apart as possible. |
False
|
Returns:
Type | Description |
---|---|
List[str]
|
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/