Named Colors#
VisualAstro adds many colors to Matplotlib when you import the package!
The colors are registered with Matplotlib so they work natively.
To preview and query the colorsets, use the va.colors interface.
See Colors for the full api.
Listing Named Colors#
List the names of all available named colors:
va.colors.available
['violetred', 'jade', ..., 'ethernet brown']
Alias names are listed separately:
>>> import visualastro as va
>>> va.colors.aliases
{'E train': 'A train', '1 train': '3 train', ..., 'celeste': 'battery charged blue'}
Accessing Named Colors#
Retrieve a color with the get() method or with
indexing (va.colors['name']):
>>> import visualastro as va
>>> va.colors.get('pondwater')
'#cfe23c'
>>> va.colors['dark verdigris']
'#43B3AE'
Plotting Colors Tables#
VisualAstro organizes the recognized colors in colortables. These are collections of curated colors,
like the VisualAstro named colors, the default Matplotlib colors, or xkcd colors. You can view a
colortable with plot(). Possible inputs are
'named_colors'orNone: VisualAstro and Matplotlib named colors'visualastro'or'va': VisualAstro named colors'matplotlib'or'mpl'or'css4': Matplotlib named colors'xkcd': XKCD named colors'base': Matplotlib base colors'tableau': Matplotlib tableau colors'all'or'all_colors': All of the above
If no input is passed in, all VisualAstro and Matplotlib colors are plotted. By default,
the colors are sorted by hue. Turn off this behavior with sort_colors=False.
VisualAstro Named Colors#
VisualAstro comes with many custom colors!
import visualastro as va
va.colors.plot('visualastro')
(Source code, svg)
Color Transforms#
You can set one of the supported color transforms to change all the colorsets automatically.
Supported transforms include 'lighten', 'darken', 'saturate', and 'desaturate'.
The intensity is controlled by factor.
import visualastro as va
va.colors.plot('visualastro', transform='desaturate', factor=0.35)
(Source code, svg)
CVD Simulations#
Warning
This requires the optional package colorspacious. See Installation Guide.
You can preview a colorset as it appears under altered color vision by
passing cvd_type as 'deuteranomaly', 'protanomaly',
'tritanomaly', or 'all' ('d', 'p', and 't' are also
accepted). The colorspacious package simulates how a viewer with that
color vision type would perceive the colorset. Use severity to set the
strength of the effect (0 to 100, default 100).
import visualastro as va
va.colors.plot('visualastro', cvd_type='deuteranomaly')
(Source code, svg)
Matplotlib Named Colors#
You can see the default Matplotlib colors as well:
import visualastro as va
va.colors.plot('matplotlib')
(Source code, svg)
XKCD Named Colors#
VisualAstro registers xkcd colors under their bare names (e.g. 'sky blue'), so the
'xkcd:' prefix is optional. Names that collide with existing Matplotlib or VisualAstro
colors keep the prefix (e.g. 'xkcd:cyan').
import visualastro as va
va.colors.plot('xkcd')
(Source code, svg)