New behavior? TH2::SetXTitle()

Hello,
I am currently using root 5.32/0 in win32. I am using the command line for the following: In the past (e.g. 5.22/0) I could draw from a tree using:

pt->Draw("y:x>>h(20,-1000,1000,20,-1000,1000)")

and then create an xaxis title with

h->SetXTitle("a title");
h->Draw("Sameaxis")

and the title would appear on the x-axis. When I do the same thing in 5.32/0 the title does not appear. However if Itype

h->GetXaxis()->GetTitle()

root displays the title that I just set on the console window. How do I make this title appear on the canvas?

Thank you
Ed

The way change the title would be:

root [0] ntuple->Draw("py:px>>h(20,-1000,1000,20,-1000,1000)")
root [1] TH2F *h2 = gPad->GetListOfPrimitives()->FindObject("h")
root [2] h2->GetXaxis()->SetTitle("new X axis title");
root [3] gPad->Modified()

In fact the “h” you access directly from the CINT prompt is not the one stored in the pad .

Changing the histogram title would be done the same way:

root [0] ntuple->Draw("py:px>>h(20,-1000,1000,20,-1000,1000)")
root [1] TH2F *h2 = gPad->GetListOfPrimitives()->FindObject("h")
root [2] h2->SetTitle("new histogram title");
root [3] gPad->Modified()

Thank you!!

Its curious that if the “colz” option is used:

ntuple->Draw("py:px>>h(20,-1000,1000,20,-1000,1000)","","colz")

then there is no need for the step:

TH2F *h2 = gPad->GetListOfPrimitives()->FindObject("h")

Ed

When you draw without option, the histogram is not drawn, but instead is drawn a frame and a graph inside (to draw the points). With a plotting option the histogram is drawn.

See:

root [0] ntuple->Draw("py:px>>h(20,-1000,1000,20,-1000,1000)")
root [1] 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= -1000.000000 Y1=-1000.000000 X2=1000.000000 Y2=1000.000000
   OBJ: TH2F	h	py:px : 1 at: 0x7fa5526fb220
   OBJ: TPaveText	title  	X1= -139.942531 Y1=1100.000026 X2=139.942531 Y2=1237.500030
   OBJ: TGraph	Graph	Graph : 1 at: 0x7fa55276b8b0


root [2] ntuple->Draw("py:px>>h(20,-1000,1000,20,-1000,1000)","","COL")
root [3] 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= -1000.000000 Y1=-1000.000000 X2=1000.000000 Y2=1000.000000
   OBJ: TH2F	h	py:px : 0 at: 0x7fa55265e4b0
   OBJ: TPaveText	title  	X1= -139.942531 Y1=1100.000026 X2=139.942531 Y2=1237.500030