# How to get the ymin, ymax values defined by SetRangeUser?

For the X-axis, I get the xmin and xmax values defined by user (using TAxis::SetRangeUser()), using the following code:

[code]
void test() {
float x = {-2,1.5,3,5,1.07};
float y = {-5,2.5,5,-1,10.07};
TGraph *g = new TGraph(5,x,y);
g->GetXaxis()->SetRangeUser(1,2);
g->GetYaxis()->SetRangeUser(0,10);
int binmin = g->GetXaxis()->GetFirst();
int binmax = g->GetXaxis()->GetLast();
float xmin = g->GetXaxis()->GetBinCenter(binmin);
float xmax = g->GetXaxis()->GetBinCenter(binmax);

float ymin = g->GetYaxis()->GetXmin();
float ymax = g->GetYaxis()->GetXmax();
std::cout << "X: " << xmin << " " << xmax << std::endl;
std::cout << "Y: " << ymin << " " << ymax << std::endl;
}[/code]
It shows

[quote]X: 1.038 1.962
Y: -6.507 11.577[/quote]
For the x-axis, it is not exactly 1 and 2 but it is sufficient for what I need.
However, this method does not work for the y axis since there is no bin in the y-axis.
Do you have any suggestion?

Hi,

The Graph is a 1D object and has only the X axis. You should not use this method for the Y axis, instead use
TGraph::SetMinimum/SetMaximum

Lorenzo