Colorsets#

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

The examples on this page assume:

import visualastro as va

Listing Colorsets#

List the names of all available colorsets:

va.colorsets.available

Alias names are listed separately:

va.colorsets.aliases

Accessing Colorsets#

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

va.colorsets.get('supernatural')
va.colorsets['celestial']

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.

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