I’m trying to plot several TGraphAsymmError with different ranges into one canvas. I’ve used a TMultiGraph to do so, but it plots always the full range.
mg = TMultiGraph()
for i in bla:
h1 = TGraphAsymmErrors()
h1.Divide(htest[i],href[i],"cl=0.683 b(1,1) mode")
h1.SetName(testname)
h1.Draw("AP") #<- Plots the correct range
h1.GetHistogram().GetXaxis().SetRangeUser(161,420)
mg.Add(h1)
mg.Draw("AP") #<- Plots full range
I’ve also tried to get the Taxis from the TGraphAsymmError and apply SetLimits. But again no changes in the resulting plot.
Thanks a lot for the answer. But I think I didn’t clearly say what my problem is.
I want different ranges for different TGraphasymmErrors in the TMultigraph.
I.e. I have several TGraph, initially reaching from 0 to 2000. Now I want to plot graph 1 only from 0 - 100, graph 2 from 50 - 500, graph 3 from 250 - 100 and so on.
So not one range for all, but a specific range for every TGraph in the TMultiGraph.
Sorry for the poor description. Perhaps an example could help.
Have a look at the attached plot.
The range of the canvas is fine. But I want e.g. the red crosses (markerstyle 3) to start at 200 and be plotted up to 800.
The blueish stars should go from 120 to 800 and the empty crosses should go from 80 - 800. EffCombined.pdf (48.2 KB)
In that case the graph with red-cross you put in the TMultiGraph should start at 200 and finish at 800.
Make a “sub graph” before putting it in the multigraph.
how do I produce such a subgraph?
I’ve tried to set the range of the Histograms used to make the TGraph (the ones from Divide(a,b, opt)), setting the limits of the TGraph, the range of the underlying histogram (via gr->getHistogram() ), changing the range of the x-axis…
Everything seems to reset as soon as I call multigraph->Add()
The only way I could think of is setting the values to 0… Which is not a very elegant way to do it…
Has there since been a more elegant solution to this problem? I have the same exact problem and would like to keep it simple, without having to create a new graph through a for loop at least?