When You Can’t See It: Managing Label Visibility in Molecular Models

One of the most common friction points for molecular modelers—especially when working in complex systems—is label clutter. Labels help annotate molecules, atoms, or processes, but when not managed properly, they can quickly overcrowd your scene or simply disappear when you need them most. Fortunately, SAMSON provides fine control over label visibility using the Node Specification Language (NSL).

In this post, we take a closer look at the Label attribute space, with a focus on how visibility is controlled through visible, visibilityFlag, and hidden properties. Whether you want to display only certain labels for clarity or toggle them programmatically through NSL expressions, understanding how these attributes work will give you more precise control over your scene.

What are label nodes?

In SAMSON, labels are specialized nodes used to display annotations, names, IDs, or any user-defined messages attached to nodes in the document. These can be highly useful for workflows involving visual debugging, communication in scientific presentations, or simply to convey additional context.

Using the label attribute space

Label-related queries in NSL use the la namespace (short for label), and several visibility-related attributes are inherited from the generic node attribute space. Here are the key ones:

la.v: The visible attribute

This controls whether a label is currently rendered. You can use this to select or hide labels in a scene:

Use this when you want to temporarily remove visual clutter or double-check which labels are not being displayed.

la.vf: The visibilityFlag attribute

This flag indicates whether a label is enabled for visibility through visibility rules. It differs from la.v as it helps in cases where visibility is dynamically changed depending on node hierarchy or scene settings.

la.h: The hidden attribute

This is a more general attribute also inherited from node, and can be used to programmatically control hidden states:

Common use cases

  • Scenario 1: You created annotation labels for active sites, but now they overwhelm your view. Use not la.v to isolate hidden ones and tweak accordingly.
  • Scenario 2: You’re importing a molecule and want only labels containing a specific prefix (like ligand names) and are visible. Try a compound NSL expression like:
    la.n "L*" and la.v
  • Scenario 3: You want to reset the visibility state of all labels. You can explicitly set la.vf and la.h to ensure things are rendered predictably.

Best practices

If you’re using labels for dynamic modeling or scripting, always remember:

  • la.v controls current rendering
  • la.vf sets whether visibility is allowed
  • la.h indicates general hidden state—not necessarily only due to label visibility

Managing these correctly ensures that labels are shown only when needed, improving visual clarity and reducing distraction.

To learn more, check out the official NSL label attributes documentation.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.

Comments are closed.