Last modified: 12 December 2018

How do I add or change a label in the plot?


The 'Annotate' menu of the GUI (also available by pressing the Right Mouse Button in a ChIPS window) allows you to add annotations, such as labels, directly from the GUI.

The add_label command is used to create a label and the set_label_text() command is used to change the text displayed by a label. In the example below we create a simple plot, add a label and then change its contents.

chips> clear()
chips> add_curve([1,2,3], [9,-2,45])
chips> add_label(1.5, 40, r"\alpha = 0.27 \pm 0.03")
chips> get_label_text()
       '\alpha = 0.27 \pm 0.03'
chips> set_label_text("alpha = 0.27 +/- 0.03")
chips> get_label_text()
       'alpha = 0.27 +/- 0.03'

When the label is initially created we use LaTeX-style notation, which means that we "protect" the string - by preceeding it with a r - to avoid the "\" being treated as an escape character. An alternative would be to write "\\" instead. When we change the label we switch to an ASCII-only display for the label text.

The ChIPS GUI

The ChIPS GUI makes it easy to modify a visualization using your mouse, rather than Python functions. The GUI can also be used to add annotations - such as labels, lines, points and regions - and to zoom or pan into plots.