Hi,
The following example shows how to reverse an axis. But the data set is
not reversed in that case. To do this, I think you should created a
temporary "reversed version" of your data along Y (something like Ymax-y)
and plot them instead of the original data.
Cheers, Olivier
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
gPad->Update();
TGaxis *newaxis = new TGaxis(gPad->GetUxmax(),
gPad->GetUymin(),
gPad->GetUxmin(),
gPad->GetUymin(),
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
510,"-");
newaxis->SetLabelOffset(-0.03);
newaxis->Draw();
}
On Tue, 20 Jul 2004, Dorota Szczygiel wrote:
> Hi!
> I have a problem of this kind:
> I need to draw y-axis upside down (bigger values lower
> than smaller values), but not only rotate the axis,
> also data points must change their place, according to
> new y-axis values.
>
> Eg: Should change to:
>
> /|\ /|\
> 9 | . 7 | . .
> | . . ---> | . .
> 7 | . . 9 | .
> |_________ |__________
>
>
>
> Thanks,
> Dorothy
>
>
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: Olivier.Couet@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET