
from java.awt import Color,Font
from java.util import Random
from jhplot import *

c1 = HPlotJa("Canvas",800,400,2,1)
c1.setAntiAlias(False)
c1.setGTitle("Title")
c1.visible()

h1 = H1D("e^{+}e^{-} &rarr; W^+{}W^{-} &rarr; 4J",20, -2.0, 2.0)
rand = Random()
# fill histogram
for i in range(500):
      h1.fill(rand.nextGaussian())

h1.setFill(1)
h1.setFillColor(Color.green)
h1.setErrX(0)
h1.setErrY(1)
h1.setPenWidthErr(2)


h2 = H1D("e^{+}e^{-} &rarr; Z/&gamma; &rarr;  X ",15, -2.0, 2.0)
h2.setFill(1)
h2.setErrX(0)
h2.setErrY(1)
h2.setFillColorTransparency(0.7)
h2.setFillColor(Color.red)
h2.setColor(Color.red)
h2.setErrColorY(Color.blue)
h2.setNameX("X of H2")
h2.setNameY("Y of H2")

for i in range(1000): 
      h2.fill(2+rand.nextGaussian())

c1.cd(1,1)
c1.setAutoRange()
# set range
# c1.setRange(-4,4,0.0,100)
c1.setLegendFont( Font("Lucida Sans", Font.BOLD, 14)  )
c1.setNameX("Text Examples:&minus; &theta; &pi; &omega; &int; &sum;")
c1.setNameY("Yaxis")
c1.setName("Canvas title: &radic;(1&minus; e)")
c1.draw(h1)


c1.cd(2,1)
c1.setAutoRange()
c1.draw(h2)

# c1.clearAll()
# c1.update()
# export to some image (png,eps,pdf,jpeg...)
# c1.export(Editor.DocMasterName()+".png");
