
from java.awt import Font,Color
from java.util import Random
from jhplot  import  HPlot,H1D

c1 = HPlot("Canvas",600,400,2, 1)

# set global title
# c1.setGTitle("Global Title", Color.blue) #put title
c1.visible(1)

h1 = H1D("e^{+}e^{-} &rarr; W^+{}W^{-} &rarr; 4 jets",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;  q#bar{q} ",15, -2.0, 2.0)
h2.setFill(1)
h2.setErrX(0)
h2.setErrY(1)
h2.setFillColorTransparency(0.7)
h2.setFillColor(Color.blue)
h2.setColor(Color.blue)
h2.setErrColorY(Color.black)
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()

c1.setBackgColor(Color.yellow)
c1.setLegendFont( Font("Lucida Sans", Font.BOLD, 12)  )
c1.setNameX("mass")
c1.setNameY("Entries")
c1.setName("Canvas &alpha;")
c1.draw(h1)
c1.draw(h2)


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

# c1.setBackgroundColor(Color.yellow)
c1.setLegendFont( Font("Lucida Sans", Font.BOLD, 12)  )
c1.setNameX("mass")
c1.setNameY("Entries")
c1.setName("Canvas &beta;")
c1.setGrid(0,0)
c1.setGrid(1,0)
c1.setRange(0, -0.5, 3.0)
c1.setShadow(1)


h1.setFillColorTransparency(1)
c1.draw(h1)
h2.setStyle("p")
c1.draw(h2)
