Talk:Label: Difference between revisions
Line 72: | Line 72: | ||
=Examples= | =Examples= | ||
<source lang="python"> | <source lang="python"> | ||
#1. | |||
# make a very simple label on the 14th alpha carbon. | # make a very simple label on the 14th alpha carbon. | ||
label n. CA and i. 14, "This is carbon 14." | label n. CA and i. 14, "This is carbon 14." | ||
#2. | |||
# make a fake scene label; use this to label entire scenes, not just atoms/bonds. | # make a fake scene label; use this to label entire scenes, not just atoms/bonds. | ||
pseudoatom foo | pseudoatom foo | ||
label foo, "Once upon a time..." | label foo, "Once upon a time..." | ||
#3. | |||
# make a huge label | # make a huge label | ||
set label_size, -5 | set label_size, -5 | ||
pseudoatom foo | pseudoatom foo | ||
label foo, "This is large text" | label foo, "This is large text" | ||
#4. Partial Charge | |||
label (chain A),chain | |||
label (n;ca),"%s-%s" % (resn,resi) | |||
label (resi 200),"%1.3f" % partial_charge | |||
#5. The gallery image above Label_ex.png was created with this code | |||
# and finally, some labels were moved around in '''edit_mode'''. | |||
label (resi 200),"%1.3f" % b | |||
set label_font_id, 10 | |||
set label_size, 10 | |||
#6. This example shows how to label a selection with the | |||
# XYZ coordinates of the atoms | |||
from pymol import stored | |||
stored.pos = [] | |||
# select the carbon atoms in my hetero atoms to label | |||
select nn, het and e. C | |||
# get the XYZ coordinates and put htem into stored.pos | |||
iterate_state 1, (nn), stored.pos.append((x,y,z)) | |||
# label all N atoms. You need the pop() function or else | |||
# PyMOL will complain b/c you didn't provide enough coords. | |||
label nn, ("%5.5s, %5.5s, %5.5s") % stored.pos.pop() | |||
</source> | </source> | ||
Revision as of 20:06, 8 June 2009
Fixes
- Updates needed
New Page Content
New Page Overview
This is the content for the new labels page.
Overview
The Label command controls how PyMOL draws text labels for PyMOL objects. Labeling is important so there are many options for your fine tuning needs. You can change the label size, label color, positioning, font, the label outline color that masks the font and much, much more.
You can have PyMOL label atoms by properties or arbitrary strings as you want; you can even use Unicode fonts for special symbols like, , etc.
The following gallery shows some examples of how extensible the Label command is.
Object Properties
Aside from arbitrary string labels, like "This is the catalytic residue" for an atom/residue you can also use the following built-in molecular properties:
- name, the atom name
- resn, the residue name
- resi, the residue number/identifier
- chain, the chain name
- q, charge
- b, the occupancy/b-factor
- segi, the segment identifier
- type (ATOM,HETATM), the type of atom
- formal_charge, the formal charge
- partial_charge, the partial charge
- numeric_type, the numeric type
- text_type, the text type
Syntax
To use the label command follow this syntax:
# labeling syntax
label [ selection[, expression]]
where selection is some object/selection you want to label and expression is some string (or set of strings) which PyMOL is to use to label the given selection.
We have plenty of examples. See the examples below.
Settings
Here are all the label settings and their general effect. For each label setting, see the respective web page for more details.
- (no idea)
- (no idea)
- sets whether or not PyMOL will ray trace shadows for your label text. Eg:
set label_shadow_mode, 2
- sets whether or not PyMOL will ray trace shadows for your label text. Eg:
- sets the color of the label text. Eg:
set label_color, magenta
- sets the color of the label text. Eg:
- sets the font to render your label. There are 12 different fonts from 5—16. Numbers 15 and 16 are special for unicode. Eg:
set label_font_id, 12
- sets the font to render your label. There are 12 different fonts from 5—16. Numbers 15 and 16 are special for unicode. Eg:
- sets the size of the text. You can use positive numbers 2, 3, 4, etc for point sizes, or negative sizes for Angstrom-based sizes: A 2Ang font woukld then be -2. Eg:
set label_size, -2
- sets the size of the text. You can use positive numbers 2, 3, 4, etc for point sizes, or negative sizes for Angstrom-based sizes: A 2Ang font woukld then be -2. Eg:
- (no idea)
- each label is outlined (so you can do white-on-white labels, for example). This options sets the color of the label outline. Eg.
set label_outline_color, orange
- each label is outlined (so you can do white-on-white labels, for example). This options sets the color of the label outline. Eg.
- (no idea)
- sets any offset from the original X,Y,Z coordinates for the label. If you like to use the mouse, you can enter edit_mode and ctrl-middle-click to drag labels around; ctrl-shift-left_click will let you move the labels in the z-direction.
Examples
#1.
# make a very simple label on the 14th alpha carbon.
label n. CA and i. 14, "This is carbon 14."
#2.
# make a fake scene label; use this to label entire scenes, not just atoms/bonds.
pseudoatom foo
label foo, "Once upon a time..."
#3.
# make a huge label
set label_size, -5
pseudoatom foo
label foo, "This is large text"
#4. Partial Charge
label (chain A),chain
label (n;ca),"%s-%s" % (resn,resi)
label (resi 200),"%1.3f" % partial_charge
#5. The gallery image above Label_ex.png was created with this code
# and finally, some labels were moved around in '''edit_mode'''.
label (resi 200),"%1.3f" % b
set label_font_id, 10
set label_size, 10
#6. This example shows how to label a selection with the
# XYZ coordinates of the atoms
from pymol import stored
stored.pos = []
# select the carbon atoms in my hetero atoms to label
select nn, het and e. C
# get the XYZ coordinates and put htem into stored.pos
iterate_state 1, (nn), stored.pos.append((x,y,z))
# label all N atoms. You need the pop() function or else
# PyMOL will complain b/c you didn't provide enough coords.
label nn, ("%5.5s, %5.5s, %5.5s") % stored.pos.pop()
See Also
All the settings posted above.