Color names

ProPlot registers several new color names and includes tools for defining your own color names. These features are described below.

Included colors

ProPlot adds new color names from the XKCD color survey and the Open Color UI design color palettes. You can use show_colors to generate a table of these colors. Note that the matplotlib’s native X11 named colors are still registered, but some of the X11 color names may be overwritten by the XKCD names, and we encourage choosing colors from the below tables instead. ProPlot registers XKCD colors because the selection is larger and the names are more likely to match your intuition for what a color “should” look like.

To reduce the number of registered color names to a more manageable size, ProPlot filters the available XKCD colors so that they are sufficiently distinct in the perceptually uniform 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'.

  1. [1]:
  1. import proplot as plot
  2. fig, axs = plot.show_colors()

_images/colors_2_0.svg

Colors from colormaps

If you want to draw an individual color from a 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 ColorDatabase 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.

  1. [2]:
  1. import proplot as plot
  2. import numpy as np
  3. state = np.random.RandomState(51423)
  4. fig, axs = plot.subplots(nrows=2, axwidth=3.2, share=0)
  5. axs.format(
  6. xformatter='null', yformatter='null', abc=True, abcloc='ul', abcstyle='A.',
  7. suptitle='Getting individual colors from colormaps and cycles'
  8. )
  9. # Drawing from colormap
  10. ax = axs[0]
  11. name = 'Deep'
  12. cmap = plot.Colormap(name)
  13. idxs = plot.arange(0, 1, 0.2)
  14. state.shuffle(idxs)
  15. for idx in idxs:
  16. data = (state.rand(20) - 0.4).cumsum()
  17. h = ax.plot(
  18. data, lw=5, color=(name, idx),
  19. label=f'idx {idx:.1f}', legend='r', legend_kw={'ncols': 1}
  20. )
  21. ax.colorbar(cmap, loc='ur', label='colormap', length='12em')
  22. ax.format(title='Drawing from the Solar colormap', grid=True)
  23. # Drawing from color cycle
  24. ax = axs[1]
  25. idxs = np.arange(6)
  26. state.shuffle(idxs)
  27. for idx in idxs:
  28. data = (state.rand(20) - 0.4).cumsum()
  29. h = ax.plot(
  30. data, lw=5, color=('qual1', idx),
  31. label=f'idx {idx:.0f}', legend='r', legend_kw={'ncols': 1}
  32. )
  33. ax.format(title='Drawing from the ggplot color cycle')

_images/colors_4_0.svg

Using your own colors

You can register your own colors by adding .txt files to the ~/.proplot/colors directory and calling register_colors. This command is also called on import. Each file should contain lines that look like color: #xxyyzz where color is the registered color name and #xxyyzz is the HEX color value. Lines beginning with # are ignored as comments.