<p>I ended up fixing this by just putting this into the boilerplate code:</p>

<pre><code>copy PolyA-MC_4, PolyA-MC
copy PolyA-MC_6, PolyA-MC
copy PolyA-MC_8, PolyA-MC
copy PolyA-MC_10, PolyA-MC
copy PolyA-MC_12, PolyA-MC
copy PolyA-MC_14, PolyA-MC
copy PolyA-MC_16, PolyA-MC
copy PolyA-MC_18, PolyA-MC
copy PolyA-MC_20, PolyA-MC
</code></pre>

<p>This copied my object such that I had one per size of label text, and then each label was placed on the object. As all labels on a given object are the same size, it worked! e.g. for one residue the labelling is now:</p>

<pre><code>set label_size,  4, PolyA-MC_4
</code></pre>

<p>Effectively, it's the same as what I was already doing, but instead of having ten copy filies in the directory only one is needed. Much easier for sending to people, and more efficient!</p>

CC BY-SA 4.0
2019-09-30T13:16:52.070Z
2019-09-30T16:05:56.563Z
2019-09-30T16:05:56.563Z
A. King
<p>'label_size' is a object-state-level setting, which means that you will have to rely on the 'create' command to create a new object for every different label size.</p>

<p>It can certainly be automated, and for this I'd recommend getting into <a href="https://pymolwiki.org/index.php/Simple_Scripting" rel="nofollow noreferrer">Pyhton Scripting for PyMOL</a></p>

CC BY-SA 4.0
2019-09-20T10:32:37.520Z
Ah, I see what you mean! The way I've been doing it with multiple objects is to just create multiple copies in the directory (So PolyA-M_1 to PolyA-M_10) such that it reads those in too, and then writes labels of different sizes onto them. But if there isn't a command which is able to change label size at a residue level, then this definitely sounds more efficient than having loads of different files. It would also be good for me to learn more scripting in general. Thank you!
A. King
CC BY-SA 4.0
2019-09-20T10:25:53.937Z
2019-09-20T10:25:53.937Z
bunher
<p>I'm new to PyMol (and StackExchange!) and working on my first project. I have the structure of a protein as an object, called PolyA-M, and the idea is that the residues of it are shown as spheres of differing sizes based on a calcualted conservation value. I want to label each sphere with it's amino acid, but to have the label size corresponding to sphere size. Here is a sample of the code that might be used to label one amino acid.</p>

<pre><code>alter ( resid 138 ), resn = "Q135"
alter ( name CB and resid 138 ), vdw = vdw * 0.8 * 0.679934640522875
set_color col138, [ 1.0, 0.181, 0.181 ]
show spheres, name CB and resi 138
show sticks, ( name CA or name CB ) and resid 138
set label_size, 14, PolyA-M
label PolyA-M and name CB and resid 138, "Q"
color col138, name CB and resi 138
</code></pre>

<p>In this case, residue 138 is medium sized sphere with a size 14 label Q that fits well. However, if later on in the code another residue is labelled as so:</p>

<pre><code>alter ( resid 198 ), resn = "A208"
alter ( name CB and resid 198 ), vdw = vdw * 0.8 * 0.359803921568627
set_color col198, [ 1.0, 0.601, 0.601 ]
show spheres, name CB and resi 198
show sticks, ( name CA or name CB ) and resid 198
set label_size,  8, PolyA-M
label PolyA-M and name CB and resid 198, "A"
color col198, name CB and resi 198
</code></pre>

<p>This will label residue 198 with a small A to fit the small sphere. However, this will also change the earlier label to size 8 as well, making it too small for the sphere.</p>

<p>Is there any way for me to prevent this, such that each residue keeps its own label size? </p>

<p>I know that one way is to create multiple identical objects and keep all labels of the same size restricted to the same object (For example, PolyA-M_10 contains all residues with label size 10, polyA-M_14 all residues with label size 14) but I was wondeirng if there is a more efficient way?</p>

<p>Thank you for any help! This is my first Stack Exchange question so any feedback would be appreciated :) </p>

<protein-structure><structural-biology><pymol>
Putting labels of different sizes on one PyMOl Object
# Putting labels of different sizes on one PyMOl Object

(Asked by: username_0 on 2019-09-20)

I'm new to PyMol (and StackExchange!) and working on my first project. I have the structure of a protein as an object, called PolyA-M, and the idea is that the residues of it are shown as spheres of differing sizes based on a calcualted conservation value. I want to label each sphere with it's amino acid, but to have the label size corresponding to sphere size. Here is a sample of the code that might be used to label one amino acid.
alter ( resid 138 ), resn = "Q135"
alter ( name CB and resid 138 ), vdw = vdw * 0.8 * 0.679934640522875
set_color col138, [ 1.0, 0.181, 0.181 ]
show spheres, name CB and resi 138
show sticks, ( name CA or name CB ) and resid 138
set label_size, 14, PolyA-M
label PolyA-M and name CB and resid 138, "Q"
color col138, name CB and resi 138

In this case, residue 138 is medium sized sphere with a size 14 label Q that fits well. However, if later on in the code another residue is labelled as so:
alter ( resid 198 ), resn = "A208"
alter ( name CB and resid 198 ), vdw = vdw * 0.8 * 0.359803921568627
set_color col198, [ 1.0, 0.601, 0.601 ]
show spheres, name CB and resi 198
show sticks, ( name CA or name CB ) and resid 198
set label_size,  8, PolyA-M
label PolyA-M and name CB and resid 198, "A"
color col198, name CB and resi 198

This will label residue 198 with a small A to fit the small sphere. However, this will also change the earlier label to size 8 as well, making it too small for the sphere.
Is there any way for me to prevent this, such that each residue keeps its own label size? 
I know that one way is to create multiple identical objects and keep all labels of the same size restricted to the same object (For example, PolyA-M_10 contains all residues with label size 10, polyA-M_14 all residues with label size 14) but I was wondeirng if there is a more efficient way?
Thank you for any help! This is my first Stack Exchange question so any feedback would be appreciated :)

**Tags:** protein-structure, structural-biology, pymol

---

## 2 answers

### Answer by username_0 on 2019-09-30. Score: 1 | Accepted answer

I ended up fixing this by just putting this into the boilerplate code:
copy PolyA-MC_4, PolyA-MC
copy PolyA-MC_6, PolyA-MC
copy PolyA-MC_8, PolyA-MC
copy PolyA-MC_10, PolyA-MC
copy PolyA-MC_12, PolyA-MC
copy PolyA-MC_14, PolyA-MC
copy PolyA-MC_16, PolyA-MC
copy PolyA-MC_18, PolyA-MC
copy PolyA-MC_20, PolyA-MC

This copied my object such that I had one per size of label text, and then each label was placed on the object. As all labels on a given object are the same size, it worked! e.g. for one residue the labelling is now:
set label_size,  4, PolyA-MC_4

Effectively, it's the same as what I was already doing, but instead of having ten copy filies in the directory only one is needed. Much easier for sending to people, and more efficient!


---

### Answer by username_1 on 2019-09-20. Score: 2

'label\_size' is a object-state-level setting, which means that you will have to rely on the 'create' command to create a new object for every different label size.

It can certainly be automated, and for this I'd recommend getting into [Pyhton Scripting for PyMOL](https://pymolwiki.org/index.php/Simple_Scripting)

> **Comments:**
> **username_0**: Ah, I see what you mean! The way I've been doing it with multiple objects is to just create multiple copies in the directory (So PolyA-M_1 to PolyA-M_10) such that it reads those in too, and then writes labels of different sizes onto them. But if there isn't a command which is able to change label size at a residue level, then this definitely sounds more efficient than having loads of different files. It would also be good for me to learn more scripting in general. Thank you!  

---

