maffe
April 12, 2017, 11:11am
#1
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!

couet
April 12, 2017, 11:31am
#2
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);
}
```

maffe
April 12, 2017, 11:49am
#3
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) ?

couet
April 12, 2017, 11:51am
#4
Have you tried my macro ?
It removes the ticks and labels. So the axis line is drawn in black … as you asked…

maffe
April 12, 2017, 12:02pm
#5
There was a misunderstanding: i would like to remove the axis line …

couet
April 12, 2017, 12:05pm
#6
and keep the labels and ticks ?

maffe
April 12, 2017, 12:23pm
#7
No; in fact remove all of them! Axis line, labels and ticks.

couet
April 12, 2017, 12:59pm
#8
```
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");
}
```

system
closed
April 26, 2017, 1:14pm
#9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.