3.15 Interactive text labels with keys. HKey class

The HKey class creates an interactive label with a text and a key describing the shown data. It should be noted that it behaves differently than the legend which is automatically shown with the corresponding data set. The HKey object is not related to any data set and can be shown even if no data are plotted. This class is rather similar to HLabel and has all the methods which HLabel has. To make it visible, call the update() method. Here is a typical example:

>>> h1 =HKey("key type=32",55,62) # show a ket at x=55 and y=62
>>> h1.setKey(32,7.0,Color.blue)  # show type 32, size=7
>>> h1.setKeySpace(4.0)           # set space between a ket and text
>>> c1.add(h1)
>>> c1.update()

Various key types are shown in Fig. :autoref Various types of the keys used by the setKey(..) method. The figure was generated by the script hkeys.py in the example directory. 3.4, which was generated by the script hkeys.py in the example directory.

Figure: Various types of the keys used by the setKey(..) method. The figure was generated by the script hkeys.py in the example directory.
[width=0.8]hkey.eps

One can include multiline interactive label with the class HMLabel. It is very similar to HLabel, however, instead of a string, it takes a list of strings. Each element of such list will be shown on a new line.

from jhplot import *
c1=HPlot()
c1.visible()
s1='ω,F^{2},F_{2},γ→e^{+} e^{-}'
s2='g → q#bar{q}'
s=[s1,s2]
lab=HMLabel(s,0.3,0.7)
c1.add(lab)
c1.update()