Colorblindfriendly: Difference between revisions
Jaredsampson (talk | contribs) (Added basic page for Colorblindfriendly.py script) |
Jaredsampson (talk | contribs) (→Download the script and run locally: Add a "run from Github" example.) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 17: | Line 17: | ||
== Colors == | == Colors == | ||
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. | |||
{| cellpadding="1" | {| cellpadding="1" | ||
|- align="center" | |- align="center" | ||
! width="20"| ||bgcolor=#ddd width="100"|name||bgcolor=#ddd width="50"|R||bgcolor=#ddd width="50"|G||bgcolor=#ddd width="50"|B||bgcolor=#ddd|alternate names | ! width="20"| ||bgcolor=#ddd width="100"|name||bgcolor=#ddd width="50"|R||bgcolor=#ddd width="50"|G||bgcolor=#ddd width="50"|B||bgcolor=#ddd|alternate names | ||
|- align="center" | |- align="center" | ||
|bgcolor=#000000| ||cb_black|| | |bgcolor="#000000"| ||cb_black||0||0||0|| | ||
|- align="center" | |- align="center" | ||
|bgcolor=#e69f00| ||cb_orange|| | |bgcolor="#e69f00"| ||cb_orange||230||159||0|| | ||
|- align="center" | |- align="center" | ||
|bgcolor=#56b4e9| ||cb_sky_blue|| | |bgcolor="#56b4e9"| ||cb_sky_blue||86||180||233||cb_skyblue, cb_light_blue, cb_lightblue | ||
|- align="center" | |- align="center" | ||
|bgcolor=#009e73| ||cb_bluish_green|| | |bgcolor="#009e73"| ||cb_bluish_green||0||158||115||cb_bluishgreen, cb_green | ||
|- align="center" | |- align="center" | ||
|bgcolor=#f0e442| ||cb_yellow|| | |bgcolor="#f0e442"| ||cb_yellow||240||228||66|| | ||
|- align="center" | |- align="center" | ||
|bgcolor=#0072b2| ||cb_blue|| | |bgcolor="#0072b2"| ||cb_blue||0||114||178|| | ||
|- align="center" | |- align="center" | ||
|bgcolor=#d55e00| ||cb_vermillion|| | |bgcolor="#d55e00"| ||cb_vermillion||213||94||0||cb_red, cb_red_orange, cb_redorange | ||
|- align="center" | |- align="center" | ||
|bgcolor=#cc79a7| ||cb_reddish_purple|| | |bgcolor="#cc79a7"| ||cb_reddish_purple||204||121||167||cb_rose, cb_violet, cb_magenta | ||
|} | |} | ||
== Usage == | |||
=== Import as a module === | |||
[[File:colorblindfriendly_menu.png|thumb|Screenshot of the <code>cb_colors</code> color menu in the OpenGL GUI in PyMOL 2.0.]] | |||
After importing the module, call the <code>set_colors()</code> function to add the colors to PyMOL's color palette. Then, use these color names just like any other named color, using the <code>[[color]]</code> command. | |||
<syntaxhighlight lang="python"> | |||
import colorblindfriendly as cbf | |||
# Add the new colors | |||
cbf.set_colors() | |||
color cb_red, myObject | |||
</syntaxhighlight> | |||
The colors can also be made to replace the built-in colors (i.e. they are created both with and without the "<code>cb_</code>" prefix.). Do this by passing the <code>replace</code> keyword argument. | |||
<syntaxhighlight lang="python"> | |||
# Replace built-in colors with cbf ones | |||
cbf.set_colors(replace=True) | |||
color yellow, myOtherObject # actually cb_yellow | |||
</syntaxhighlight> | |||
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 <code>cb_colors</code> menu item, which expands to give all the color blind-friendly colors, except black, which is available in the <code>grays</code> menu. | |||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
# Add a `cb_colors` menu to the OpenGL GUI (see screenshot) | |||
# This will also add the colors if `set_colors()` hasn't yet been run. | |||
cbf.add_menu() | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Run the latest version of the script from Github === | |||
In a PyMOL session, run at the command line: | |||
run https://github.com/Pymol-Scripts/Pymol-script-repo/raw/master/colorblindfriendly.py | |||
This will add all the colors as well as the OpenGL menu. | |||
=== Download the script and run locally === | |||
Save the script from the link in the box at the top right to your computer. | |||
In a PyMOL session, run at the command line: | |||
run /path/to/colorblindfriendly.py | |||
This will add all the colors as well as the OpenGL menu. | |||
== Requirements == | |||
The <tt>cb_colors</tt> GUI menu (generated by the <tt>add_menu()</tt> function) requires PyMOL 1.6.0 and later. | |||
Latest revision as of 14:21, 15 November 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 |
Introduction
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.
Colors
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 |
Usage
Import as a module
After importing the module, 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.
import colorblindfriendly as cbf
# Add the new colors
cbf.set_colors()
color cb_red, myObject
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
cbf.set_colors(replace=True)
color yellow, myOtherObject # 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 to the OpenGL GUI (see screenshot)
# This will also add the colors if `set_colors()` hasn't yet been run.
cbf.add_menu()
Run the latest version of the script from Github
In a PyMOL session, run at the command line:
run https://github.com/Pymol-Scripts/Pymol-script-repo/raw/master/colorblindfriendly.py
This will add all the colors as well as the OpenGL menu.
Download the script and run locally
Save the script from the link in the box at the top right to your computer.
In a PyMOL session, run at the command line:
run /path/to/colorblindfriendly.py
This will add all the colors as well as the OpenGL menu.
Requirements
The cb_colors GUI menu (generated by the add_menu() function) requires PyMOL 1.6.0 and later.