visualastro.Colorsets#
- class Colorsets[source]#
Bases:
_ColorRegistry[list[tuple[float,float,float] |str|tuple[float,float,float,float] |tuple[tuple[float,float,float] |str,float] |tuple[tuple[float,float,float,float],float]]]Query and plot registered VisualAstro colorsets.
See colorset guide for usage documentation.
- property available#
Canonical names of the registered VisualAstro colorsets.
Aliases and Matplotlib built-in colorsets (e.g.
'tab10') are excluded. Usealiasesto list alias names.
- property aliases#
Mapping of colorset aliases to canonical names.
Only aliases registered in the Matplotlib color sequence registry are included.
- Returns:
Keys are alias names, values are the canonical names in
availablethey resolve to.- Return type:
dict of str to str
See also
availableCanonical colorset names.
- get(name, *, fmt='hex', transform=_Unset.UNSET, factor=_Unset.UNSET, cvd_type=None, severity=100)[source]#
Get a colorset by name or alias.
Thin wrapper around
get_colorset(). See that function for the full description of the options.- Parameters:
name (str) – Colorset name or alias.
fmt ({'hex', 'rgb', 'rgba'}, optional, default='hex') – Output color format.
transform ({'lighten', 'darken', 'saturate', 'desaturate'} | None, optional) – Color transform to apply. Default is set by
get_colorset.factor (float, optional) – Transform strength. Default is set by
get_colorset.cvd_type ({'deuteranomaly', 'protanomaly', 'tritanomaly'} | None, optional, default=None) – Color vision deficiency to simulate.
severity (int, optional, default=100) – Severity of the simulated deficiency.
- Returns:
Colors in the requested format.
- Return type:
See also
visualastro.get_colorsetUnderlying implementation.
- query(*, length=None, min_length=None, max_length=None, sort_by=None, reverse=False)[source]#
Filter and sort colorset names.
- Parameters:
length (int | None, optional, default=None) – Absolute length of colors.
min_length (int | None, optional, default=None) – Minimum number of colors (inclusive).
max_length (int | None, optional, default=None) – Maximum number of colors (inclusive).
sort_by ({'name', 'length'} | None, optional, default=None) – Sort criterion. If
None, registration order is kept.reverse (bool, optional, default=False) – Reverse the sort order.
- Returns:
names – Matching canonical colorset names.
- Return type:
- Raises:
ValueError – If
sort_byis not a valid criterion.
- plot(colorset=None, *, show_color_name=True, length=None, min_length=None, max_length=None, sort_by=None, reverse=False, transform=_Unset.UNSET, factor=_Unset.UNSET, cvd_type=None, severity=100, width=8, savefig=False)[source]#
Plot the colorset(s), optionally with additional filters.
Any of the filters in
query()are valid arguments ifcolorsetisNone.- Parameters:
colorset (str | None, optional, default=None) – Colorset name or alias, or a color or sequence of colors. If
None, plots all colorsets unless one or more of the filters are used.show_color_name (bool, optional, default=True) – If
True, also plots the colorset name. Only applicable to VisualAstro colorsets (as opposed to a sequence of colors).length (int | None, optional, default=None) – Absolute length of colors.
min_length (int | None, optional, default=None) – Minimum number of colors (inclusive).
max_length (int | None, optional, default=None) – Maximum number of colors (inclusive).
sort_by ({'name', 'length'} | None, optional, default=None) – Sort criterion. If
None, registration order is kept.reverse (bool, optional, default=False) – Reverse the sort order.
transform ({'lighten', 'darken', 'saturate', 'desaturate'} | None | _Unset, optional, default=_UNSET) – Method to modify the colors. If
None, colors are unchanged. If_UNSET, usesconfig.color_transform.factor (float | _Unset, optional, default=_UNSET) – Modification strength, see
get_colors. If_UNSET, usesconfig.color_transform_factor.cvd_type ({'deuteranomaly', 'protanomaly', 'tritanomaly', 'all'} | None, optional, default=None) – Type of colorblindness to simulate. Can be shorthanded to
'd','p','t'. If'all', simulates all cvd types. IfNone, no colorblindness simulation is applied.severity (float, optional, default=100) – Severity of colorblindness. Must be < 100.
width (float | int | None, optional, default=8) – Width of the colorset plot.
savefig – If
True, save the figure to disk withsavefig. Opens a prompt to set the file name and extention.
- Return type:
None
- preview(colorset, *, cmap=_Unset.UNSET, linestyle='solid', linewidth=2, transform=_Unset.UNSET, legend=True, loc='bottom center', ncols=4, factor=_Unset.UNSET, cvd_type=None, severity=100)[source]#
Plot a sample figure demonstrating a VisualAstro color set.
- Parameters:
colors (ColorType | int | Sequence[ColorType | int], optional, default='astro_seq') – Color set to visualize. Can be either a VisualAstro colorset name, a color, an integer, or a sequence of colors. If an
int, generates a sequence of colors by samplingcmap.ax (matplotlib.axes.Axes | None, optional, default=None) – The Axes object on which to plot the demo orbits. If
None, usesplt.gca().cmap (Colormap | _Unset, optional, default=_UNSET) – Colormap used to generate a sequence of colors if
colorsis an int. If_UNSETusesconfig.colors.linestyle (LineStyleType, optional, default='solid') – Line style of each line.
linewidth (float, optional, default=2) – Line width of each line.
legend (bool, optional, default=True) – If
True, plots the legend.loc (str, optional, default='bottom center') – Legend location.
ncols (int, optional, default=4) – Number of columns in the legend.
transform ({'lighten', 'darken', 'saturate', 'desaturate'} | None | _Unset, optional, default=_UNSET) – Method to modify the colors. If
None, colors are unchanged. If_UNSET, usesconfig.color_transform.factor (float | _Unset, optional, default=_UNSET) – Modification strength, see
get_colors. If_UNSET, usesconfig.color_transform_factor.cvd_type ({'deuteranomaly', 'protanomaly', 'tritanomaly', 'all'} | None, optional, default=None) – Type of colorblindness to simulate. Can be shorthanded to
'd','p','t'. If'all', simulates all cvd types. IfNone, no colorblindness simulation is applied.severity (float, optional, default=100) – Severity of colorblindness. Must be < 100.
- Return type:
None