TGraphErrors: Errors not showing

Hi,
I am facing following problem, when I create one TGraphErrors and create an error band with 3AC* option, it is drawn normally only if I do not create another TGraphErrors.
To make my issue clear, let’s say I have following piece of code:
TGraphErrors * g = new TGraphErrors(…);
TGraphErrors * gr = new TGraphErrors(…);

g->Draw(“3AC*”);

It draws just as if it is normal TGraph. But if I delete “gr” , then it is drawn with errors.

What can be the cause of this and possible solution?

Thanks!

Can you post a small macro that demonstrates this problem?

I will try to explain as much as possible.
So, I have vectors that are being filled:

std::vector<Double_t> eff1;
std::vector<Double_t> eff2;
std::vector<Double_t> eff1_err;
std::vector<Double_t> eff2_err;

eff1.push_back(…);
eff2.push_back(…);
eff3.push_back(…);
eff1_err.push_back(…);
eff2_err.push_back(…);

TGraphErrors g1(TGraphErrors(&eff3.size(), &eff3[0], &eff1[0], 0, &eff1_err[0]));
TGraphErrors g2(TGraphErrors(&eff3.size(), &eff3[0], &eff2[0], 0, &eff2_err[0]));

TCanvas c = new TCanvas(" … ");
g1.SetFillColor(10);
g1.SetLineColor(2);
g1.SetMarkerStyle(20);
g1.Draw("3AC
");

g2.SetFillColor(3);
g2.SetLineColor(kRed+2);
g2.SetMarkerStyle(20);
g2.Draw(“3P”);
c->SaveAs(“graphs.pdf”);

It is something like this, very close to this actually! And in this case error bars (error band) only of the first graph are drawn, while for the other one only line is drawn (like normal TGraph).
I am trying to draw both TGraphErrors on the same canvas.
Just as a side note: The size of the vectors is the same.

Thank you for attention and if there is something else what I can provide you with that may be useful for solving this problem, please just ask.

P.S. I could share with you my actual macro, but privately, however I am not sure whether it is possible here.

Try with:

  // ...
  g1.Draw("A3"); g1.Draw("CP");
  // ...
  g2.Draw("3"); g2.Draw("LP");
  gPad->Modified(); gPad->Update();
  c->SaveAs("graphs.pdf");

BTW. Are you sure the errors of the second graph are big enough to be visible (also note that color 10 is “white”)?

Thank you for your fast response. It works now, when I do separately first g1.Draw(“A3”); and then g1.Draw(“CP”);
I do not really understand why it does not work in one go, like g1.Draw(“3ACP”); but good that it works like this! :slight_smile:
Thank you once again for helping me out!