From: John Stone (
Date: Tue Feb 28 2017 - 16:55:41 CST

  The VMD text rendering code doesn't currently possess logic to deal with
various possible text formatting scenarios other than the simplest case of
writing out a linear string of characters. If you want to draw formatted
paragraphs of text or multi-line text labels, I would suggest doing that
by writing a more complex version of your existing "label_atom" routine
such that it parses the incoming string, and generates a separate VMD
"draw" command for each linear string, but computing its own Y-coordinate
from the current line. You could use the Tcl "split" command to break
the incoming text at each linefeed or CRLF pair to produce a list of
strings, and then do a Tcl foreach loop incrementing a current line count,
and multiplying that line count against a Y-coordinate vertical spacing
to get a new starting point for each drawn text label. This should be pretty
easy to write and would work with all existing and past versions of VMD.

  John Stone

On Mon, Feb 27, 2017 at 06:35:04PM +0200, Garold Murdachaew wrote:
> Dear VMD Community,
> I would like to place some user-defined labels near atomic positions.
> I am using these commands:
> proc label_atom {selection_string label_string} {
> set sel [atomselect top $selection_string]
> if {[$sel num] != 1} {
> error "label_atom: '$selection_string' must select 1 atom"
> }
> # get the coordinates of the atom
> lassign [$sel get {x y z}] coord
> # and draw the text
> draw color purple
> draw text $coord $label_string size 0.6 thickness 3
> }
> graphics top delete all
> set mylabel [format "%s \n %7.3f" C168 0.134]
> label_atom index=168 $mylabel
> set mylabel [format "%s \n %7.3f" C223 0.123]
> label_atom index=223 $mylabel
> However, I am finding that the newline character \n, which should work
> in tcl, has no effect. I have also tried vertical tab, \v, also to no
> effect.
> Is there a way to vertically space labels? I need to do this to make
> the figure legible.
> Doing this in a separate program by hand would be quite tedious (I
> need to do this for a few frames of a number of trajectories, about 20
> labels per frame), and prone to error. Thus I would like to automate
> this as much as possible.
> Thank you in advance for your suggestions,
> Garold

NIH Center for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801           Phone: 217-244-3349