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.
You can annotate your figure on the HPlot canvas putting interactive labels, so you can move them around with the mouse and edit.
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.
can be shown as “X^{2}”
can be shown as “X_{2}”
To indicate over-line, use the reserved word “\bar{}”:
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 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.
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.
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
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: