# TGraph, TAxis and the axis with decreasing values

Hello,
it is possible to draw the X axis of TGraph with decreasing values?
For example, I create an array like this for x values

``````    Double_t* xas = new Double_t;
for(int i=1535; i>=0; i--)
xas[1535-i]=i;
``````

(with decreasing values), I create an array yas with some values and I create the TGraph:

TGraph* g = new TGraph(1536, xas, yas);

but some strange phenomena occour:

1. the data in the graph are displayed correctly (that is means that the position of the data are displayed as if the xaxis report descreasing values from 1535 to 0. This means that the yas value is displayed on the left side of the graph)
2. the label of the xaxis are not correct (that is means that the label starts from 0 - in the left side - to 1535 and not from 1535 to 0). I need the label start from 1535 (left side) to 0 (right side).
There is a solution for this problem?

Thank you very much
Best regards
Andrea Bulgarelli

There is no simple option to do that in ROOT. The axis values are always increasing from left to right on the X axis and from bottom to top on the Y axis. We need to find a user infertace (option) (any idea ?) to implement this facility. Meanwhile I can propose you, as workaround, the following macro:

``````reverseaxis ()
{
TH2F *hpxpy  = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
Float_t px, py;
TRandom r;
for (Int_t i = 0; i < 25000; i++) {
r.Rannor(px,py);
hpxpy->Fill(px,py);
}
TCanvas *c1 = new TCanvas("c1");
hpxpy->Draw("colz");
ReverseXAxis(hpxpy);
}

ReverseXAxis (TH1 *h)
{
// Remove the current axis
h->GetXaxis()->SetLabelOffset(999);
h->GetXaxis()->SetTickLength(0);

// Redraw the new axis