In [1]:
import ROOT
In [2]:
c = ROOT.TCanvas()
The simple graph
In [3]:
g = ROOT.TGraph()
for i in range(5): g.SetPoint(i,i,i*i)
g.Draw("APL")
c.Draw()
Change marker style, colour as well as line colour and thickness. Make the plot interactive. Re-draw the plot and interact with it!
In [4]:
%jsroot on
g.SetMarkerStyle(ROOT.kFullTriangleUp)
g.SetMarkerSize(3)
g.SetMarkerColor(ROOT.kAzure)
g.SetLineColor(ROOT.kRed - 2)
g.SetLineWidth(2)
g.SetLineStyle(3)
c.Draw()
Now we set the title and the grid on the canvas.
In [5]:
g.SetTitle("My Graph;The X;My Y")
c.SetGrid()
c.Draw()
We will now add the symbol of the Calcium isotope
In [6]:
txt = "#color[804]{My text #mu {}^{40}_{20}Ca}"
l = ROOT.TLatex(.2, 10, txt)
l.Draw()
c.Draw()
Redraw using a Y axis in log scale.
In [7]:
c.SetLogy()
c.Draw()