color changes the color of an object or an atom selection.
color color-name color color-name, object-name color color-name, (selection)
cmd.color( string color, string selection )
Using RGB for Color
If you prefer RGB to color any object
set_color newcolor, [r,g,b] color newcolor
List of Color Values
Color all carbons yellow
color yellow, (name C*)
set_color khaki, [195,176,145] color khaki
The command to color your molecule by B-Factors (B Factors) is:
where SEL is your selection, for example, "protA and n. CA", for protein A's alpha carbons.
Reassigning B-Factors and Coloring
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 "0", 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.
# load the protein cmd.load("protA.pdb") # open the file of new values (just 1 column of numbers, one for each alpha carbon) inFile = open("newBFactors", 'r') # create the global, stored array stored.newB =  # read the new B factors from file for line in inFile.readlines(): stored.newB.append( float(line) ) # close the input file inFile.close() # clear out the old B Factors alter protA, b=0.0 # update the B Factors with new properties alter protA and n. CA, b=stored.newB.pop(0) # color the protein based on the new B Factors of the alpha carbons cmd.spectrum("b", "protA and n. CA")