Delete x axes without painting in white

Hi rooters,

I have a transparent pad in which I draw a TGraphErrors with option .Draw('AL, Y+).
I would need to remove the X axis (including labels), but not painting in white, since there is another plot in a pad below, and that would have some white.

If I remove the A (axis) draw option no plot appears.

I’m open to alternatives.

Thanks!

for instance:

void graph() {
   TCanvas *c = new TCanvas("c","A Simple Graph without axis",700,500);

   const Int_t n = 10;
   TGraph *gr = new TGraph(n);
   gr->SetTitle("A Simple Graph Example");
   gr->SetMarkerStyle(20);


   Double_t x, y;
   for (Int_t i=0;i<n;i++) {
      x = i*0.1;
      y = 10*sin(x+0.2);
      gr->SetPoint(i,x,y);

   }

   gr->Draw("ALP");

   gr->GetXaxis()->SetLabelSize(0);
   gr->GetYaxis()->SetLabelSize(0);
   gr->GetXaxis()->SetTickLength(0);
   gr->GetYaxis()->SetTickLength(0);
}

Thanks couet, but I would still have the axis visible (in black).
Is there a way to remove it without using the command gr.GetXaxis().SetAxisColor(0) ?

Have you tried my macro ?
It removes the ticks and labels. So the axis line is drawn in black … as you asked…

There was a misunderstanding: i would like to remove the axis line …

and keep the labels and ticks ?

No; in fact remove all of them! Axis line, labels and ticks.

void graph() {
   TCanvas *c = new TCanvas("c","A Simple Graph without axis",700,500);
   c->Range(-0.1,0.,1.,10.);

   const Int_t n = 10;
   TGraph *gr = new TGraph(n);
   gr->SetMarkerStyle(20);

   Double_t x, y;
   for (Int_t i=0;i<n;i++) {
      x = i*0.1;
      y = 10*sin(x+0.2);
      gr->SetPoint(i,x,y);
   }
   gr->Draw("LP");
}

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