Hi I have written a script in PyROOT through my python interpreter (PyCharm) which takes data from a TTree and creates a TGraph. The script runs smoothly however I no visualization of the graph appears, does anyone else have this issue? I have tried with another script found on the ROOT guides as well which results in the same issue. The script I found and have used for an example to get a better understanding og TGraphs through python is:
from __future__ import print_function import ROOT from math import sin from array import array c1 = ROOT.TCanvas( 'c1', 'A Simple Graph Example', 200, 10, 700, 500 ) c1.SetFillColor( 42 ) c1.SetGrid() n = 20 x, y = array( 'd' ), array( 'd' ) for i in range( n ): x.append( 0.1*i ) y.append( 10*sin( x[i]+0.2 ) ) print(' i %i %f %f ' % (i,x[i],y[i])) gr = ROOT.TGraph( n, x, y ) gr.SetLineColor( 2 ) gr.SetLineWidth( 4 ) gr.SetMarkerColor( 4 ) gr.SetMarkerStyle( 21 ) gr.SetTitle( 'a simple graph' ) gr.GetXaxis().SetTitle( 'X title' ) gr.GetYaxis().SetTitle( 'Y title' ) gr.Draw( 'ACP' ) # TCanvas.Update() draws the frame, after which one can change it c1.Update() c1.GetFrame().SetFillColor( 21 ) c1.GetFrame().SetBorderSize( 12 ) c1.Modified() c1.Update()
Does anyone know why I don’t get a visualization of my graph when running this code?
Thank you for all help!