dt-stormer-verlet.root (708.2 KB)
readroot.py (1.5 KB)
I’m trying to format a TTree graph that I’m piping to a TGraph object (g1) in python 2.7.
Here’s a look at the libraries.
import ROOT
from ROOT import TTree,TFile,gROOT
from ROOT import TCanvas,TGraph,TPad,TBrowser
I read in the root tree file.
file=TFile("dt-stormer-verlet.root", "read");
tree=file.Get("time-sequence")
Then I try to plot the two branches (box.atoms.KE_PE_V_AVG:box.atoms.dt)
c=TCanvas("c", "canvas", 800, 800)
c.GetFrame().SetBorderSize(12)
c.cd()
tree.SetLineStyle(3)
tree.SetLineColor(2)
tree.SetLineWidth(4)
tree.SetMarkerColor(1)
tree.SetMarkerStyle(2)
tree.Draw("box.atoms.KE_PE_V_AVG:box.atoms.dt>>g1","dt<2","")
g1=TGraph(tree.GetSelectedRows(),tree.GetV2(),tree.GetV1())
g1.SetTitle( 'a simple graph' )
g1.Draw("")
g1.SetTitle( 'a simple graph' )
g1.GetXaxis().SetTitle('X title')
g1.GetYaxis().SetTitle("Y title")
c.SetGrid()
c.Modified()
c.Update()
text=raw_input()
The issue I am having is the title, and axis labels are not printing on the canvas and I am not sure why. Suggestions, questions, solutions would be greatly appreciated. Thanks!