In [2]:
import ROOT
In order to activate the interactive visualisation we can use the JSROOT magic:
In [3]:
%jsroot on
Now we will create a histogram specifying its title and axes titles:
In [5]:
h = ROOT.TH1F("myHisto","My Histo;X axis;Y axis",64, -4, 4)
Time to create a random generator and fill our histogram:
In [6]:
rndmGenerator = ROOT.TRandom3()
for i in xrange(1000):
rndm = rndmGenerator.Gaus()
h.Fill(rndm)
In [7]:
c = ROOT.TCanvas()
h.Draw()
c.Draw()
We'll try now to beautify the plot a bit, for example filling the histogram with a colour and setting a grid on the canvas.
In [9]:
h.SetFillColor(ROOT.kBlue-10)
c.SetGrid()
h.Draw()
c.Draw()
Alright: we are done with our first step into the ROOTbooks world!