Change direction of x-Axis


is there a way to change the direction of the x-axis of a histogram, graph, etc. (or of a canvas) from ‘left to right’ to ‘right to left’?

The reason for this is that the coordinate system for our calorimeter has increasing x-values from the right to the left (if you are looking in the direction of the beam, y-axis heading up). Thus, if I plot the position of hits, clusters, etc. I get a picture that is the mirror image to what I have in mind.

The only solution I have in mind, to plot “-x” instead of “x” helps a little bit, but still is confusing because this changes the coordinates, and thus the axis label is wrong.

Is there a way to flip the direction of the Axis in an easy way for “quick and dirty” plots?

Cheers, J.

Here is an example.
reverseaxis.C (1.47 KB)

This already helps a little bit, at least to produce nice final plots. Thank your for your answer.

But the main problem remains. If I use your script to swap the (x-)axis, I still have to fill the histogram with the negative x-values. But this is rather inconvenient, since the histogram then contains the “wrong” values. What I mean is the following: If i fill the histogram with the values (-x,y) and swap the x-axis after that, then the bin with the label -3,1 has the value of the “correct” value. But if I ask the histogram to return the number of entries of the bin at position (-3,1), then I get the entries of the bin at (3,1) instead of the correct value.

Is there a way to flip a whole histogram instead of flipping only the axis?
Cheers, J.