Dear Users,
I have a very simple question on how to change the y-axis range of a histogram plot. I have tried TH1D.GetYaxis().SetRange()
, TH1D.GetYaxis().SetRangeUser()
, TH1D.SetMaximum
but none of them have an effect on my plot. I have also tried calling these commands in different lines. Here is my code:
canvas = TCanvas("Histogram", "Histogram", 100, 200, 700, 500)
canvas.cd()
hist1.Draw("Hist")
hist2.Draw("same")
hist1.GetYaxis().SetTitle("Frequency")
hist1.GetXaxis().SetTitle("m_{T}")
#Here is what I've tried:
#hist1.SetMaximum(150.)
#hist1.GetYaxis().SetRange(0.,150.)
#hist1.GetYaxis().SetRangeUser(0.,150.)
canvas.Clear()
Both hist1
and hist2
are TH1D
objects. Does anyone know what Iām doing wrong?