<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Domsicj</id>
	<title>PyMOL Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Domsicj"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php/Special:Contributions/Domsicj"/>
	<updated>2026-06-10T11:41:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Color&amp;diff=5180</id>
		<title>Color</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Color&amp;diff=5180"/>
		<updated>2008-05-20T15:53:39Z</updated>

		<summary type="html">&lt;p&gt;Domsicj: reversed order of &amp;quot;ramp_obj&amp;quot; and &amp;quot;your-objec-name&amp;quot; for the &amp;quot;set surface_color&amp;quot; option.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION===&lt;br /&gt;
'''color''' changes the color of an object or an atom selection.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
 color color-name&lt;br /&gt;
 color color-name, object-name&lt;br /&gt;
 color color-name, (selection)&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;cmd.color( string color, string selection )&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using RGB for Color==&lt;br /&gt;
If you prefer RGB to color any object&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
set_color newcolor, [r,g,b]&lt;br /&gt;
color newcolor&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
List of [[Color Values]]&lt;br /&gt;
&lt;br /&gt;
==EXAMPLES==&lt;br /&gt;
===Color all carbons yellow===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;color yellow, (name C*)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RGB Example===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
set_color khaki, [195,176,145]&lt;br /&gt;
color khaki&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Color by Spectrum Example===&lt;br /&gt;
Color by spectrum is in the GUI menu but did you realize that the spectrum is not limited to a simple rainbow?&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
spectrum count, x, object_name&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
x can can be anyone of the following:&lt;br /&gt;
blue_green, green_white_magenta, red_cyan, blue_magenta, green_white_red, red_green, blue_red, green_white_yellow, red_white_blue, blue_white_green, green_yellow, red_white_cyan, blue_white_magenta, green_yellow_red, red_white_green, blue_white_red, magenta_blue, red_white_yellow, blue_white_yellow, magenta_cyan, red_yellow, blue_yellow, magenta_green, red_yellow_green, cbmr, magenta_white_blue, rmbc, cyan_magenta, magenta_white_cyan, yellow_blue, cyan_red, magenta_white_green, yellow_cyan, cyan_white_magenta, magenta_white_yellow, yellow_cyan_white, cyan_white_red,  magenta_yellow, yellow_green, cyan_white_yellow, rainbow, yellow_magenta, cyan_yellow, rainbow2, yellow_red, gcbmry, rainbow2_rev, yellow_white_blue, green_blue, rainbow_cycle, yellow_white_green, green_magenta, rainbow_cycle_rev, yellow_white_magenta, green_red, rainbow_rev, yellow_white_red, green_white_blue, red_blue, yrmbcg &lt;br /&gt;
&lt;br /&gt;
===B-Factors===&lt;br /&gt;
The command to color a molecule by B-Factors (B Factors) is:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cmd.spectrum(&amp;quot;b&amp;quot;, selection=&amp;quot;SEL&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where '''SEL''' is a valid selection, for example, &amp;quot;protA and n. CA&amp;quot;, for protein A's alpha carbons.&lt;br /&gt;
&lt;br /&gt;
You can choose the spectrum you want with the command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cmd.spectrum(&amp;quot;b&amp;quot;, 'rainbow', selection=&amp;quot;SEL&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where '''rainbow''' is a valid selection from the list:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  blue_green            green_white_magenta   red_cyan            &lt;br /&gt;
  blue_magenta          green_white_red       red_green           &lt;br /&gt;
  blue_red              green_white_yellow    red_white_blue      &lt;br /&gt;
  blue_white_green      green_yellow          red_white_cyan      &lt;br /&gt;
  blue_white_magenta    green_yellow_red      red_white_green     &lt;br /&gt;
  blue_white_red        magenta_blue          red_white_yellow    &lt;br /&gt;
  blue_white_yellow     magenta_cyan          red_yellow          &lt;br /&gt;
  blue_yellow           magenta_green         red_yellow_green    &lt;br /&gt;
  cbmr                  magenta_white_blue    rmbc                &lt;br /&gt;
  cyan_magenta          magenta_white_cyan    yellow_blue         &lt;br /&gt;
  cyan_red              magenta_white_green   yellow_cyan         &lt;br /&gt;
  cyan_white_magenta    magenta_white_yellow  yellow_cyan_white   &lt;br /&gt;
  cyan_white_red        magenta_yellow        yellow_green        &lt;br /&gt;
  cyan_white_yellow     rainbow               yellow_magenta      &lt;br /&gt;
  cyan_yellow           rainbow2              yellow_red          &lt;br /&gt;
  gcbmry                rainbow2_rev          yellow_white_blue   &lt;br /&gt;
  green_blue            rainbow_cycle         yellow_white_green  &lt;br /&gt;
  green_magenta         rainbow_cycle_rev     yellow_white_magenta&lt;br /&gt;
  green_red             rainbow_rev           yellow_white_red    &lt;br /&gt;
  green_white_blue      red_blue              yrmbcg &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Reassigning B-Factors and Coloring====&lt;br /&gt;
It is commonplace to replace the B-Factor column of a protein with some other  biochemical property at that residue, observed from some calculation or experiment.  PyMOL can easily reassign the B-Factors and color them, too.  The following example will load a protein, set ALL it's B Factors to &amp;quot;0&amp;quot;, read in a list of properties for each alpha carbon in the proteins, assign those new values as the B-Factor values and color by the new values.  This example is possible because commands PyMOL  does not recognize are passed to the Python interpreter --- a very powerful tool.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# load the protein&lt;br /&gt;
cmd.load(&amp;quot;protA.pdb&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# open the file of new values (just 1 column of numbers, one for each alpha carbon)&lt;br /&gt;
inFile = open(&amp;quot;newBFactors&amp;quot;, 'r')&lt;br /&gt;
&lt;br /&gt;
# create the global, stored array&lt;br /&gt;
stored.newB = []&lt;br /&gt;
&lt;br /&gt;
# read the new B factors from file&lt;br /&gt;
for line in inFile.readlines(): stored.newB.append( float(line) )&lt;br /&gt;
&lt;br /&gt;
# close the input file&lt;br /&gt;
inFile.close()&lt;br /&gt;
&lt;br /&gt;
# clear out the old B Factors&lt;br /&gt;
alter protA, b=0.0&lt;br /&gt;
&lt;br /&gt;
# update the B Factors with new properties&lt;br /&gt;
alter protA and n. CA, b=stored.newB.pop(0)&lt;br /&gt;
&lt;br /&gt;
# color the protein based on the new B Factors of the alpha carbons&lt;br /&gt;
cmd.spectrum(&amp;quot;b&amp;quot;, &amp;quot;protA and n. CA&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to save the file with the new B Factor values for each alpha carbon,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cmd.save(&amp;quot;protA_newBFactors.pdb&amp;quot;, &amp;quot;protA&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
or similar is all you need.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Expanding to Surface =====&lt;br /&gt;
If you have run the above code and would like the colors to be shown in the [[Surface]] representation, too, then you need to do the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Assumes alpha carbons colored from above.&lt;br /&gt;
create ca_obj, your-object-name and name ca &lt;br /&gt;
ramp_new ramp_obj, ca_obj, [0, 10], [-1, -1, 0]&lt;br /&gt;
set surface_color, ramp_obj, your-object-name&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thanks to Warren, for this one.&lt;br /&gt;
&lt;br /&gt;
[[Category:Objects_and_Selections]]&lt;br /&gt;
[[Category:Commands|color]]&lt;/div&gt;</summary>
		<author><name>Domsicj</name></author>
	</entry>
</feed>