Reversing X-Axis

I used these lines of code for plotting graph shown below using data available in data.txt file. In plot, the range of X-Axis is from 0 to 14,000 and I want to make 16,000 to 2000. What should I do to invert X-Axis?

graph1()
{
g = new TGraph(“data.txt”);
g->SetMarkerStyle(6);
g->SetTitle(“H-R Diagram;Temperature (K); Absolute Magitude”);
g->Draw(“AP”);
}


Please read tips for efficient and successful posting and posting code

ROOT Version: 5.34/38
Platform: Ubuntu 19.04
Compiler: Not Provided


On a new version of root, you can use

Draw(“APRX”)

https://root.cern.ch/doc/master/classTGraphPainter.html#GP03b
Otherwise you can use https://root.cern.ch/root/html/tutorials/hist/reverseaxis.C.html to reverse the axis, and reverse the TGraph by hand

The ${ROOTSYS}/tutorials/hist/reverseaxis.C macro does NOT really reverse axes. It only draws “fake” reversed axes on top of the original plot (which is not reversed).

The “RX” and “RY” graph draw options (ROOT 6.09/03 and newer) do properly reverse them when drawing graph data points.

Try the ready-to-use ROOT 6.20/04 (dated 2020.04.01) for Ubuntu 19.04 / x86_64 / gcc 8.3 binary distribution (see “Using binaries” on the “Downloading ROOT” web page).

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