I want to draw a graph and change the title of that graph in a interactive mode, what I did is:
root -l something.root
tree->Draw("adc:Iteration$>>g", "", "AL", 1, 0)
But the title was not changed after I typed such code. Why is that?
Please read tips for efficient and successful posting and posting code
ROOT Version: v6.26.02
root  ntuple->Draw("px:py","","AL");
root  Graph->SetTitle("hello");
I got the error says:
use of undeclared identifier 'ntuple'
well, the tree I use to test is called “ntuple” …the one in hsimple.root. In your case it is “tree” …
Then I should did exactly what you did…but the canvas was not updated on the screen…
In my case with the latest root on Mac the canvas is created by the draw command then the title is displayed with the 2nd command.
I just tried again, when I use:
tree->Draw("py:px", "", "AL", 1, 0);
It worked (notice that if without
c1->Modified() it didn’t work
But if I do this:
tree->Draw("py:px>>g", "", "AL", 1, 0);
It didn’t work.
SO I got 2 questions:
- In the second case, does
>>g mean that copy the TGraph to a new one called “g”? So the original one been drawn is still called “Graph”
- Why I need
c1->Modified() but you don’t…?
In that case “g” must be a 2D histogram not a TGraph see the doc
That’s true, but still I have the same two questions above… TGraph or TH2 should not affect the conditions, the first question will be like:
>>g mean that copy the TH2 to a new one called “g”? So the original one been drawn is still called “Graph”
When you draw a TTree as a 2D scatter plot a TGraph called “Graph” is automatically created:
root  ntuple->Draw("px:py")
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root  gPad->ls()
Canvas Name=c1 Title=c1 Option=
TCanvas fXlowNDC=0 fYlowNDC=0 fWNDC=1 fHNDC=1 Name= c1 Title= c1 Option=
OBJ: TList TList Doubly linked list : 0
TFrame X1= -4.500000 Y1=-4.500000 X2=5.000000 Y2=5.000000
OBJ: TH2F htemp px:py : 1 at: 0x7f8ca84c3c00
OBJ: TPaveText title X1= -0.413163 Y1=5.475000 X2=0.913163 Y2=6.128125
OBJ: TGraph Graph Graph : 1 at: 0x600000434bb0
Ah, now I understood.
>>g is just another object been created and nothing about the original
Graph. Thank you!
Exactly, and the object after
>> must be a histogram any way, not a TGraph.