# This example shows how to read ROOT file with histograms
from java.awt import Color
from jhplot import *
from jhplot.io import *
file="Example.root"
Web.get("http2://datamelt.org/examples/data/"+file)
# location of ROOT file
rfr = FileRoot( file )
print "number of histograms=",rfr.getNKeys()
print "ROOT version=",rfr.getVersion()
print "ROOT version=",rfr.getTitle()
print "No of histograms=",rfr.toString()
# get ROOT histograms
h1 = rfr.getH1D("mainHistogram")
h2 = rfr.getH1D("totalHistogram")
# create canvas 1x1
c1 = HPlot("Canvas",600,400,1, 1)
c1.setGTitle("Show ROOT histograms")
c1.visible(1)
c1.setMarginLeft(90)
c1.setRange(0, -4, 4)
c1.setAutoRange(1,1)
h1.setColor(Color.blue)
h1.setFill(True)
h1.setFillColor(Color.blue)
c1.draw(h1)
p2=P1D(h2) # show as dots
h2.setColor(Color.red)
c1.draw(p2)
c1.setNameX("Xaxis")
c1.setNameY("Yaxis")
c1.setName("Canvas title")
c1.update()