Re: Invert axis labels

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Thu, 24 Dec 2009 17:27:20 +0100


Hi Dmitry,

You can draw a TGaxis on top of your picture (eg in place of the Xaxis) as shown in the example below.
see doc of TGaxis and the special constructor where you can specify a mapping function (here "-x")

Rene Brun

void mx() {

   TF1 *f1 = new TF1("f1","-x",-3,3);
   TH1F *h = new TH1F("h","test",100,-3,3);    h->FillRandom("gaus",5000);
   TCanvas *c1 = new TCanvas("c1");
   h->Draw();
   c1->Update();
   h->GetXaxis()->SetLabelOffset(99);

   Double_t xmin = c1->GetUxmin();
   Double_t xmax = c1->GetUxmax();
   Double_t ymin = c1->GetUymin();

   TGaxis *axis = new TGaxis(xmin,ymin,xmax,ymin,"f1");    axis->Draw();
}

Dmitry Kotov wrote:
> Hi guys,
>
> Is there any simple way to invert axis labels?
> For example i have 1 2 3 4 5 6 7 and i need to place them like 7 6 5 4
> 3 2 1
>
> Thanks,
> Cheers,
> Dmitry
>
>
Received on Thu Dec 24 2009 - 17:27:35 CET

This archive was generated by hypermail 2.2.0 : Sun Dec 27 2009 - 05:50:05 CET