DiscreteColormap¶
- class DiscreteColormap(colors, name=None, N=None, alpha=None, **kwargs)[source]¶
Bases:
matplotlib.colors.ListedColormap
,proplot.colors._Colormap
Replacement for
ListedColormap
.- Parameters
alpha (
float
, optional) – The opacity for the entire colormap. Overrides the input colors.- Other Parameters
*args, **kwargs – Passed to
ListedColormap
.
Methods Summary
append
(*args[, name, N])Append arbitrary colormaps onto this colormap.
concatenate
(*[, new_obj, message])copy
([colors, name, N, alpha])Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.
from_file
(path, *[, warn_on_failure])Load color cycle from a file.
reversed
([name])Return a reversed version of the colormap.
save
([path, alpha])Save the colormap data to a file.
set_alpha
(alpha)Set the opacity for the entire colormap.
shifted
([shift, name])Return a cyclically shifted version of the colormap.
truncate
([left, right, name])Return a truncated version of the colormap.
truncated
(*[, new_obj, message])updated
(*[, new_obj, message])Methods Documentation
- append(*args, name=None, N=None, **kwargs)[source]¶
Append arbitrary colormaps onto this colormap.
- Parameters
*args – Instances of
DiscreteColormap
.name (
str
, optional) – The name of the new colormap. Default is'_'.join(cmap.name for cmap in args)
.N (
int
, optional) – The number of colors in the colormap lookup table. Default is the number of colors in the concatenated lists.
- Other Parameters
**kwargs – Passed to
copy
.
See also
- concatenate(*, new_obj=<function DiscreteColormap.append>, message="'concatenate' was deprecated in version 0.6 and will be removed in a future release. Please use 'append' instead.", **kwargs)¶
- copy(colors=None, name=None, N=None, *, alpha=None)[source]¶
Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.
- Parameters
name (
str
) – The name of the new colormap. Default is'_name_copy'
.colors, N, alpha (optional) – See
DiscreteColormap
. If not provided, these are copied from the current colormap.
- classmethod from_file(path, *, warn_on_failure=False)[source]¶
Load color cycle from a file.
- Parameters
path (path-like) – The file path. Valid file extensions are shown in the below table.
Extension
Description
.hex
Comma-delimited list of HEX strings.
.rgb
,.txt
3-4 column table of channel values.
warn_on_failure (
bool
, optional) – IfTrue
, issue a warning when loading fails instead of raising an error.
See also
- reversed(name=None, **kwargs)[source]¶
Return a reversed version of the colormap.
- Parameters
name (
str
, optional) – The name of the new colormap. Default is'_name_r'
.- Other Parameters
**kwargs – Passed to
DiscreteColormap.copy
- save(path=None, alpha=True)[source]¶
Save the colormap data to a file.
- Parameters
path (path-like, optional) – The output filename. If not provided, the colormap is saved in the
cycles
subfolder inuser_folder
under the filenamename.hex
(wherename
is the color cycle name). Valid extensions are described in the below table.Extension
Description
.hex
Comma-delimited list of HEX strings.
.rgb
,.txt
3-4 column table of channel values.
alpha (
bool
, optional) – Whether to include an opacity column for.rgb
and.txt
files.
See also
- set_alpha(alpha)[source]¶
Set the opacity for the entire colormap.
- Parameters
alpha (
float
) – The opacity.
See also
- shifted(shift=1, name=None)[source]¶
Return a cyclically shifted version of the colormap.
- Parameters
See also
- truncate(left=None, right=None, name=None)[source]¶
Return a truncated version of the colormap.
- Parameters
left (
float
, optional) – The colormap index for the new “leftmost” color. Must fall between0
andself.N
. For example,left=2
deletes the two first colors.right (
float
, optional) – The colormap index for the new “rightmost” color. Must fall between0
andself.N
. For example,right=4
deletes colors after the fourth color.name (
str
, optional) – The name of the new colormap. Default is'_name_copy'
.
See also
- truncated(*, new_obj=<function DiscreteColormap.truncate>, message="'truncated' was deprecated in version 0.6 and will be removed in a future release. Please use 'truncate' instead.", **kwargs)¶
- updated(*, new_obj=<function DiscreteColormap.copy>, message="'updated' was deprecated in version 0.6 and will be removed in a future release. Please use 'copy' instead.", **kwargs)¶