Colors and fonts

ProPlot registers several new color names and font families. These are described below.

Included color names

ProPlot defines new color names from the XKCD color survey, official Crayola crayon colors, and from the “Open color” Github project. This was inspired by seaborn. Use show_colors to generate tables of these colors. Note that the native matplotlib CSS4 named colors are still registered, but we encourage using colors from the tables instead.

To reduce the number of registered color names to a more manageable size, ProPlot filters the available XKCD and Crayola colors so that they have sufficiently distinct coordinates in the perceptually uniform hue-chroma-luminance colorspace. This makes it a bit easier to pick out colors from the table generated with show_colors. Similar names were also cleaned up – for example, 'reddish' and 'reddy' are changed to 'red'.

import proplot as plot
figs = plot.show_colors()

Drawing from cmaps and cycles

If you want to draw an individual color from a smooth colormap or a color cycle, use color=(cmap, coord) or color=(cycle, index) with any command that accepts the color keyword. The coord should be between 0 and 1, while the index is the index on the list of cycle colors. This feature is powered by the ColorDict class. This is useful if you spot a nice color in one of the available colormaps and want to use it for some arbitrary plot element.

import proplot as plot
import numpy as np
state = np.random.RandomState(51423)
f, axs = plot.subplots(nrows=2, aspect=2, axwidth=3, share=0)
# Drawing from colormap
ax = axs[0]
cmap = 'deep'
m = ax.pcolormesh([[0], [1]], cmap=cmap, N=1000)
idxs = plot.arange(0, 1, 0.2)
for idx in idxs:
    h = ax.plot((np.random.rand(20) - 0.4).cumsum(), lw=5, color=(cmap, idx),
                label=f'idx {idx:.1f}', legend='r', legend_kw={'ncols': 1})
ax.colorbar(m, loc='ul', locator=0.2, label='colormap')
ax.format(title='Drawing from the Solar colormap', grid=True)
# Drawing from color cycle
ax = axs[1]
idxs = np.arange(6)
for idx in idxs:
    h = ax.plot((np.random.rand(20)-0.4).cumsum(), lw=5, color=('qual1', idx),
                label=f'idx {idx:.0f}', legend='r', legend_kw={'ncols': 1})
ax.format(title='Drawing from the ggplot color cycle')
axs.format(xlocator='null', abc=True, abcloc='ur', abcstyle='A.',
           suptitle='Getting individual colors from colormaps and cycles')

Included font names

DejaVu Sans is the default matplotlib font, but it’s not very aesthetically pleasing. ProPlot adds a few sans-serif fonts, introduces a show_fonts command to display the available sans-serif fonts on your system, and tries to make the default font. Generally speaking, simple, clean sans-serif fonts are more appropriate for figures than serif fonts.

You can register your own fonts by adding .ttf and .otf files to the ~/.proplot/fonts directory and calling register_fonts (which is also called on import). To change the default font, use the rc object or modify your ~/.proplotrc. See Configuring proplot for details.

import proplot as plot
f = plot.show_fonts()