from jhplot import *
from jhplot.io import *
from java.util import Random

h1=H1D('Simple1',20, -2.0, 2.0)
r=Random()
for i in range(1000):
      h1.fill(r.nextGaussian())
hb = HBook("output.jdat","w") # HBook object
hb.write("data",h1)           # write histogram
hb.close()

print "Reading the histogram"
hb = HBook("output.jdat")  # read HBook object
print hb.getKeys()         # print all the keys
h2=hb.get("data")
c1 = HPlot("Canvas")
c1.setGTitle("Histograms from a file");
c1.visible(1)
c1.setAutoRange()
c1.draw(h2)
