Colorsets#

VisualAstro provides va.colorsets, an interface for viewing, querying, and plotting the registered colorsets. See Colorsets for the full API.

Listing Colorsets#

List the names of all available colorsets:

>>> import visualastro as va
>>> va.colorsets.available
['visualastro', 'ditto', ..., 'mosaic']

Alias names are listed separately:

>>> import visualastro as va
>>> va.colorsets.aliases
{'va': 'visualastro', 'vb': 'ditto', 'mozaic': 'mosaic'}

Accessing Colorsets#

Retrieve a colorset with the get() method or with indexing (va.colorsets['name']):

>>> import visualastro as va
>>> va.colorsets.get('turbo6')
['#35359a', '#4f65ff', '#5bffd9', '#c4ff05', '#ff7d3c', '#ab0449']
>>> va.colorsets['celestial']
['#08E3B2', '#0DB1FF', '#2E7F91', '#6565B5', '#3137A1', '#1F2861', '#A10E4F', '#CF3C4F', '#C76AAE']

Querying Colorsets#

You can refine your search criteria when selecting a colorset with query(). This allows you to set minimum or maximum bounds to the number of colors with min_length and max_length, or set an exact length with length. You can further sort by 'length' or 'name' with sort_by.

# all colorsets with 7 colors
va.colorsets.query(length=7)

# colorsets with more than 3 colors but less than 8 sorted by length
va.colorsets.query(min_length=3, max_length=8, sort_by='length')

Preview a Colorset#

You can plot a sample figure with a colorset using preview().

import matplotlib.pyplot as plt

import visualastro as va

plt.style.use('stix')
va.colorsets.preview('supersequential')
plt.show()

(Source code, svg)

../_images/plot_colorset_preview.svg

Plotting Colorsets#

You can also view the colorsets with plot(). This method works just like query() but plots the colorset instead as a row of colors. If no input is passed in, all colorsets are plotted.

Setting Minimum and Maximum Lengths#

Plot only the colorsets in the range [min_length, max_length].

import visualastro as va

va.colorsets.plot(min_length=9, max_length=None)

(Source code, svg)

../_images/plot_colorset_min_length.svg

Setting a Set Length#

import visualastro as va

va.colorsets.plot(length=11)

(Source code, svg)

../_images/plot_colorset_length.svg

Setting a Transform#

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.colorsets.plot(length=8, transform='desaturate', factor=0.35)

(Source code, svg)

../_images/plot_colorset_transform.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.colorsets.plot('celestial', cvd_type='all')

(Source code, svg)

../_images/plot_colorset_cvd.svg

Plotting All Colorsets#

import visualastro as va

va.colorsets.plot()

(Source code, svg)

../_images/plot_colorset_all.svg