DMelt:Plots/8 Plot Annotations

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member
Contents

Plot annotations

Data can be annotated using interactive legends and labels. In this section we will briefly discuss main components to annotate data points. For annotations, use strings. You can include Greek or math symbols as explained below.

Greek symbols

All labels and legends or any string which can be shown on a canvas can contain Greek letters. The table below shows how to encode Greek letters:

Entity nameAppearanceEntity nameAppearanceEntity nameAppearance
ααβ β γ γ
δ δ ε ε ζ ζ
η η θ θ ϑ ϑ
ι ι κ κ λ λ
μ μ ν ν ξ ξ
π π ϖ ϖ ρ ρ
σ σ ς ς τ τ
υ υ φ φ ϕ ϕ
χ χ ψ ψ ω ω
Γ Γ Δ Δ Θ Θ
Λ Λ Ξ Ξ Π Π
Σ Σ ϒ ϒ Φ Φ
Ψ Ψ Ω Ω

Mathematical operators

All labels and legends or any string which can be shown on a canvas can contain math operators:

Entity nameAppearanceEntity nameAppearanceEntity nameAppearance
⊥± ± ∨
∧≤≥
≡≈ ≈ ≠
⊂⊆⊃
⊇∈←
→↑↓
↔⇐⇒
⇑⇓⇔ ⇔
∀∃&inf; &inf;
∇

You can find more symbols in Unicode Consortium for HTML symbols.

Alternatively, you can use characters using numbers. See the unicode table unicode table When defining a Unicode character, use "&", followed by "#", then a number and then close it with a semi-column. For example, the string:

s="W^{ ∓}"

will show a W boson with minus and plus sign, ∓.

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 jhplot.HPlot canvas. You cannot interact with the mouse using such labels.

Interactive labels

You can annotate your figure on the jhplot.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.

  • "X^{2}" will be shown as [math]X^{2}[/math]
  • "X_{2}" will be displayed as [math]X_{2}[/math]


To indicate over-line, use the reserved word #bar{}. For example, to display [math]\overline{X+Y}[/math], use #bar{X+Y}. To display a square root $\sqrt{X+Y}$, use #sqrt{X+Y}.

To make a space between characters, use the usual space. To make a back-space, use the predefined keyword #bs2{}. This creates a backspace with the width of one character. To make a smaller backspace, equal to 1/2 of the character width, use #bs1{}.

One can mix this syntax to show complicated mathematical equations in the labels.

Symbols must be encoded using the entity reference notation as shown in the above sections. For example, the Greek "omega" should be written as "ω"

This is a small example that shows data points and create labels using mathematical symbols and Greek letters.

The Jython / Python script that creates this figure is given below. You can use the Java syntax to create a similar plot.

which shows this image:

DMelt example: An example of a plot with mathematical symbols and greek letters


Interactive legends

Interactive legends are used to annotate data points, functions or histograms. Be default, once data are plotted, data annotation is also displayed using title of the data (getTitle()) as a text for the key. Still, one can set legends for data manually. Look at the API of the jhplot.HKey class.

In this example, we have disabled automatic legends and made legends using the jhplot.HKey class. We plot 3 different objects, which we pass to the HKey to make legends.

The position of legends are set automatically. This example generates the figure below:

DMelt example: HKey key shown on HPlot

The legend can show symbols, lines or filled areas, and in fact, their positions can be set manually. In fact, to make a legend, there is no need to use input plotted objects.

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".

Legends are fully customizable. In the example below we change many attributes of legends

DMelt example: Multiple objects and manually setting interactive keys with HKey

The figure was generated with the example code shown below. Here we change many default attributes of the standard legends using the Python codding:

LaTeX equations

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

The output is shown here:

DMelt example: Annotations on 2D canvaces. Show a LaTeX equation

More information on this topic is in DMelt books