Colors
Handling the colors in the calendar plots.
This module provides some helper function and some defaults. However, they might not be the best of all purposes.
Color maps here take floats to a color string. Usually a hex string.
Example
Create a color map for count data.
ColorMap
Bases: ScalarMappable
This supports colorbar for a figure from matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
norm
|
matplotlib.colors.Normalize |
required | |
cmap
|
matplotlib.cm.ScalarMappable |
required | |
default_cm
|
CM
|
matplotlib.cm.ScalarMappable |
required |
Source code in latent_calendar/plot/colors.py
add_colorbar(ax=None)
Add the colorbar to axis or axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax
|
single or np.ndarray of Axes |
None
|
create_cmap(max_value, min_value=0.0, cm=None)
Create color map function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_value
|
float
|
maximum value for the color map |
required |
min_value
|
float
|
minimum value for the color map |
0.0
|
cm
|
CM | None
|
function that takes a value and returns a color |
None
|
Source code in latent_calendar/plot/colors.py
create_diverge_cmap(center_value, range, cm=None)
Create color map function to emphasize a center value and deviation from that center.
Might be good for values that are relative to some baseline
Source code in latent_calendar/plot/colors.py
create_relative_cmap(range)
settle_data_and_cmap(data, divergent)
Return a tuple of transformed data and cmap for displaying that data.