Plot annotations

Simple labels

The package jhplot.shapes can be used to display several geometrical primitives, pictures, including the text labels. All of this works together with the HPlot canvas. You cannot interact with the mouse using such labels.

Interactive labels

You can annotate your figure on the HPlot canvas putting interactive labels, so you can move them around with the mouse and edit.

  • HLabel a standard single-line label
  • HLabelEq an interactive multiline label
  • HKey interactive key to annotate shown data

The text labels can be set manually or via the label property window (click on the interactive label to bring up a dialog). Subscripts and superscripts in the text should be included as for the standard LaTeX syntax.

X^{2} can be shown as “X^{2}”

X_{2} can be shown as “X_{2}”

To indicate over-line, use the reserved word “\bar{}”:

\overline{X} can be shown as “\bar{X}”

Symbols must be encoded in HTML using the entity reference notation of the ARENA project. For example, the Greek “omega” should be written as ”ω”

Interactive keys

Interactive keys are used to annotate data points, functions or histograms. Look at the API of the HKey class. The keys can show symbols, lines or filled areas.

key.py
from java.awt import Color
from jhplot  import *
c1 = HPlot("Canvas",600,550)
c1.removeAxes()
c1.setRange(0,100,0,100)
key = HKey("My symbol",15,100)
c= Color(0,100,0)
key.setKey(0,2.0,c)
c1.add(hh)

Here we created an interactive label (type=0) at the position x=15,y=100 which shows a symbol (open circle). The type of the symbol (0) is set using the method “setKey”.

The figure below shows various types of the HKey symbols.

LaTeX equations

If you are using HPlot, you can show complex LaTeX equations using the class HLabelEq. This example shows how to make such a label using NDC coordinate system. It also shows to to put an interactive label

example1.py
from jhplot  import *
from java.awt import *
from java.util import Random
 
c1 = HPlot("Canvas",600,400,1, 1)
c1.visible(1)
c1.setAutoRange()
 
h1 = H1D("Simple1",30, -2, 2.0)
rand = Random()
# fill histogram
for i in range(1000):
      h1.fill(rand.nextGaussian())
c1.draw(h1)
c1.setAutoRange()
c1.setNameX("X_{sub}")
c1.setNameY("Y^{sup}")
c1.setName("Canvas title")
 
# set HLabel in the normilised coordinate system
lab=HLabel("HLabel F_{2}", 0.8, 0.8, "NDC")
lab.setColor(Color.blue)
c1.add(lab)
 
# show latex equation 
lab=HLabelEq("\int_{i=1}^{100}\omega_{i}(x)dx+\sum_{i=0}^{200}\sqrt{i^2}", 0.15, 0.8, "NDC")
lab.setFontSize(16)
lab.setColor(Color.blue);
c1.add(lab)
 
c1.update()

Look at the output plot:

plot_annotations.txt · Last modified: 2010/07/06 15:07 by admin
Back to top
GNU Free Documentation License 1.2
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0