Drawing TGraph for a given range


_ROOT Version: 5,6
_Platform: Linux
_Compiler: g++ 4.9


Hello,

want to plot TGraph within a given range; I’m using the obvious command,

GraphName->GetXaxis()->SetLimits(1.0, 3.0);
GraphName->Draw(“L”);

But it doesn’t work. Plots always the initial range of TGraph (0.1, 3.0);
TGraphs are in TPad but this is irrelevant; Any idea on this? thanks,

Damir

Try

GraphName->GetXaxis()->SetRangeUser(1.0, 3.0);

Hello,

usually it work for me by first drawing the graph, then setting the axis range:

GraphName->Draw("L");
GraphName->GetXaxis()->SetLimits(1.0, 3.0);
gPad->Modified();
gPad->Update();

A.

Good idea, but didn’t work;

Stand alone TGraph works with this commands but it seems since I have TPads 2x3 with histograms, then this causes some confusion on TGraph!

Actually I want to keep my Axis range from histogram; Not cut the Axis it self; i.e. I want to plot fit for user Range…Hopefully this makes sense,

If you have multiple pads in a canvas, probably you need to update the right subpad to have it working properly.

If I got correctly what you mean you need something like:

GraphName->GetFunction("<yourfunctionname>")->SetRange(1.0, 3.0);

then you may have to update the corresponding subpad.

A.

Ok maybe I’m asking something that doesn’t exist; Its a TGraph that is drawn by “L”; When plotted
I want a user given range, not changing the histograms axis limit defined; So, its not a fit function just TGraph points,

Damir

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Can you provide a small macro showing what you have right now ?