Answers.Body: <p>It is a glitch in PyMOL.</p>
  <p><strong>Caveat</strong>. I would say that, whereas <code>cmd.label</code> is great for adding labels en-mass for internal figures, it is not great for figures for dissemination (which require few <em>strategically</em> placed labels possibly with a faint white outer glow —cf. your D330): most figures in papers I would say are Powerpoint or Photoshop labelled.</p>
  <p>You called it 'labelbox', this is not a normal term, so you may be using a custom script. The box is normally called a <code>bounding box</code> and <code>connector line</code>. To add it you need to set a few values. You may have done the following:</p>
  <pre><code>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.
  </code></pre>
  <p>The issue is the <code>set label_position, [5, 5, 5]</code>. If you give the camera-based reference vector <code>[0,0,5]</code> 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.</p>
  <p>To make matters worse, the shadow is horrendous and in a random location and <code>label_shadow_mode</code> does not stop it. Let's not even discuss <code>ray_label_connector_flat</code>. So the best way to avoid this is to simply label in Photoshop, which is much more convenient anyway.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-04T11:00:58.520Z
Answers.LastActivityDate: 2021-06-04T11:00:58.520Z
Answers.UserDisplayName: Matteo Ferla
Body: <p>I would like to ask how to overcome the problem of mismatched boxes and labels (pic). Is there an option focused on this?
  thanks</p>
  <p>Radim<a href="https://i.sstatic.net/Dor4l.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Dor4l.png" alt="enter image description here" /></a></p>
  
Tags: <visualization><pymol><3d-structure>
Title: Label and labelbox mismatched in Pymol after ray
ThreadText: # Label and labelbox mismatched in Pymol after ray
  
  (Asked by: username_0 on 2021-06-03)
  
  I would like to ask how to overcome the problem of mismatched boxes and labels (pic). Is there an option focused on this?
  thanks
  
  username_0[![enter image description here](https://i.sstatic.net/Dor4l.png)](https://i.sstatic.net/Dor4l.png)
  
  **Tags:** visualization, pymol, 3d-structure
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-04. Score: 1
  
  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.
  
  
  ---
  
  