AXIS EQUAL Command

Hi everyone,

I am new in Root. Is there any command in ROOT to make the units of x and y axes equal. There is a simple command in Matlab for this purpose:
axis equal
Is there any similar command in ROOT?

Best wishes,
H. Hedayati


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


In mathlab axis equal means “axis equal: sets the aspect ratio so that the data units are the same in every direction”
In ROOT you would make it by setting the pad/canvas size in such way the unit length on each axis is the same,
Which ROOT object do you plan to use to plot your data ?

I want to draw the results of a planetary simulation by ROOT. As you can see In Matlab figure, when I use “axis equal” option, the output figure is in correct aspect ratio. But I didn’t find any similar command in ROOT. I use TGraphErrors and TMultiGragh objects. OrbitMatlab|604x500

.

Create your canvas square.

Thanks. But your approach is not general, and in cases where the scales of the axes are not the same, it will leads to the wrong aspect ratio. As an example, an ellipse orbit in Matlab and the same orbit in ROOT: OrbitMatlab|690x356

The correct aspect ratio for the canvas can be easily computed from the axis scales,

Do you have to state the obvious? One expects that a professional package like ROOT has a simple command (e.g. in TAxis class) for this simple job!

If a such functionality will be added it surely will not be in the TAxis class. This class deals with individual axis for histograms and does not have the global knowledge of the full plot. I guess we can start writing a general macro doing this and then see in which class it will fit best.

Thanks for your consideration!

and indeed a such general macro is already proposed here:
https://root-forum.cern.ch/t/set-real-aspect-ratio-of-th2-or-tgraph

I made a PR to implement this feature. Thanks to have pop up again this question.

This PR is now in the master.

Thanks, Very much!

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