Same scale in the three axis

Hi there!

I would like to draw a T2DGraph with the same scale at each axis. In order to do that, I have calculated the maximum of the differences between the maximum and the minimum of each axis. Then, I have calculated the mean point of each axis and I have added +/- the half of the previous distance.

This is shown at the code below:

distance = max(max((f2DPlot->GetXmax()-f2DPlot->GetXmin()),
(f2DPlot->GetYmax()-f2DPlot->GetYmin())),
(f2DPlot->GetZmax()-f2DPlot->GetZmin())) / 2;

medX = (f2DPlot->GetXmax() + f2DPlot->GetXmin()) / 2;
medY = (f2DPlot->GetYmax() + f2DPlot->GetYmin()) / 2;
medZ = (f2DPlot->GetZmax() + f2DPlot->GetZmin()) / 2;

f2DPlot->GetXaxis()->SetLimits(medX-distance,medX+distance);
f2DPlot->GetYaxis()->SetLimits(medY-distance,medY+distance);
f2DPlot->GetZaxis()->SetLimits(medZ-distance,medZ+distance);

If I print out the value of limits, they are ok. However, when I call the method Draw(), the limits of the z axis are not the ones they are printed.

What had happened?

I thank your help in advance.

Francisco Iguaz
University of Zaragoza

Which option are you using in the Draw() method ?

Hi couet!

I’m using the option “PO”. The complete method in which I got a problem is at the attached file.

Many thanks in advance.

Francisco Iguaz
University of Zaragoza
Method.cxx (1.67 KB)

The attached example does what you want.
graph2dminmax.C (679 Bytes)

Hi couet!

Thank you for your help. It worked perfectly.

Cheers

Paco