# Aitoff plots with X-axis reversed

Hi all,

I have built a 2D histogram defined in the ranges from -180 to 180 in X and from -90 to 90 in Y (it is a sky map with galactic latitude vs galactic longitude).

I would like to plot this histogram using an AITOFF projection, but with the X axis reversed, i.e. I want the galactic longitude +180° to appear on the left side of the plot and the galactic longitude -180° to appear on the right side of the plot.

I know that a possible solution is to make a copy of my original histogram and fill it by changing the original X values into -X.

However, is there any trick/option that I can use to do the plot without defining and filling a new histogram?

This is on our program of work. Right now the only way will be to make a new histogram (as you said) and also redraw the axis in the reverse way like in the following example. But that’s only tricks.

``````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);
ReverseYAxis(hpxpy);
}

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

// Redraw the new axis
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
510,"-");
newaxis->SetLabelOffset(-0.03);
newaxis->Draw();
}

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

// Redraw the new axis
h->GetYaxis()->GetXmin(),
h->GetYaxis()->GetXmax(),
510,"+");
newaxis->SetLabelOffset(-0.03);
newaxis->Draw();
}``````