# Label and labelbox mismatched in Pymol after ray

I would like to ask how to overcome the problem of mismatched boxes and labels (pic). Is there an option focused on this? thanks

It is a glitch in PyMOL.

Caveat. I would say that, whereas cmd.label is great for adding labels en-mass for internal figures, it is not great for figures for dissemination (which require few strategically placed labels possibly with a faint white outer glow —cf. your D330): most figures in papers I would say are Powerpoint or Photoshop labelled.

You called it 'labelbox', this is not a normal term, so you may be using a custom script. The box is normally called a bounding box and connector line. To add it you need to set a few values. You may have done the following:

label name CA and resi 44, 'Foo'
set label_outline_color, 0xff8c69  # font colour to salmon
set label_connector_color, 0xff8c69 # connect or bounding box
set label_bg_outline, true  # adds a border (lowercase bool)
set label_connector, true   # adds a line
set label_connector_mode, 1 # how the line looks label_position
set label_position, [5, 5, 5]  # offset the label
set ray_label_connector_flat, true # cylinders as line? No thanks.


The issue is the set label_position, [5, 5, 5]. If you give the camera-based reference vector [0,0,5] you get no line as Z is depth. This ray traces fine. Otherwise the glitch you found happens. My guess is that the box (but not the label) gets calculated based on the viewport window size, not the ray trace window size. So my guess is that there is a resolution and ray trace window size combination just right that they do align... but on my machine at least this is low res.

To make matters worse, the shadow is horrendous and in a random location and label_shadow_mode does not stop it. Let's not even discuss ray_label_connector_flat. So the best way to avoid this is to simply label in Photoshop, which is much more convenient anyway.