Difference between revisions of "Colorblindfriendly"

From PyMOLWiki
Jump to: navigation, search
(Usage: Update usage for version 0.2; Add requirements section.)
m (Usage: fix object name for consistency)
Line 62: Line 62:
# Replace built-in colors with cbf ones
# Replace built-in colors with cbf ones
color my_other_object, yellow  # actually cb_yellow
color myOtherObject, yellow  # actually cb_yellow

Revision as of 00:42, 26 October 2017

Type Python Script
Download colorblindfriendly.py
Author(s) Jared Sampson
License MIT
This code has been put under version control in the project Pymol-script-repo


Certain colors are indistinguishable to people with the various forms of color blindness, and therefore are better not used in figures intended for public viewing.

This script generates a palette of named colors for PyMOL that are unambiguous both to colorblind and non-colorblind individuals.

The colors listed here are defined according to recommendations found at J*FLY. This website is a good reference to consult when making all kinds of figures, not just those made using PyMOL.


These are the 0-255 RGB values from the J*FLY page that are used in the script, with the defined color names and alternate names.

  name R G B alternate names
  cb_black 0 0 0
  cb_orange 230 159 0
  cb_sky_blue 86 180 233 cb_skyblue, cb_light_blue, cb_lightblue
  cb_bluish_green 0 158 115 cb_bluishgreen, cb_green
  cb_yellow 240 228 66
  cb_blue 0 114 178
  cb_vermillion 213 94 0 cb_red, cb_red_orange, cb_redorange
  cb_reddish_purple 204 121 167 cb_rose, cb_violet, cb_magenta


Screenshot of the cb_colors color menu in the OpenGL GUI in PyMOL 2.0.

After importing the module,

import colorblindfriendly as cbf

call the set_colors() function to add the colors to PyMOL's color palette. Then, use these color names just like any other named color, using the color command.

# Add the new colors
color myObject, cb_red

The colors can also be made to replace the built-in colors (i.e. they are created both with and without the "cb_" prefix.). Do this by passing the replace keyword argument.

# Replace built-in colors with cbf ones
color myOtherObject, yellow   # actually cb_yellow

One can also add an entry to the color menu in the right-side OpenGL GUI. So clicking on [C], there will now be a cb_colors menu item, which expands to give all the color blind-friendly colors, except black, which is available in the grays menu.

# Add a cb_colors menu item to the OpenGL GUI ([C] menu in the right panel)
# this also adds the colors


The add_menu() function and OpenGL cb_colors menu currently only works with PyMOL 2.0 and later.