Draw TGraph with option E2

Hello,

I am trying to draw a graph with the option E2 (a rectangle for the error):

TGraphAsymmErrors Q2graph = (TGraphAsymmErrors)graphs->At(4);
Q2graph->SetFillColor(kRed);
Q2graph->SetFillStyle(3005);
Q2graph->Draw("*E2");

Setting of the fill colour works just fine but the the fill style is ignored and instead the standart option “solid” is used. Funny enough in the legend the specified fill option is therefore making the plot inconsistent.

Can someone tell how to specify the fill option for the error rectangles? By the way I would also be nice to be able to draw a black line around the error rectangle.

See you
Marc-Oliver

I cannot reproduce your problem. Could you try with the following script?

[code]void example() {
TCanvas *c1 = new TCanvas(“c1”,“gerrors2”,200,10,700,500);
c1->DrawFrame(-0.4,0,1.2,12);

const Int_t n = 10;
Double_t x[] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
Double_t y[] = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
Double_t ex[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
Double_t ey[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
TGraphErrors *gr = new TGraphErrors(n,x,y,ex,ey);
gr->SetFillColor(kRed);
gr->SetMarkerColor(kBlue);
gr->SetMarkerStyle(21);
gr->Draw(“e2LP”);

TLegend *legend = new TLegend(0.15,0.75,0.30,0.85,"",“brNDC”);
legend->AddEntry(gr,“mygraph”,“flp”);
legend->Draw();
}
[/code]

Concerning your request to draw a line around the boxes, this could be implemented as an option (Olivier for you).

Rene

Hi,

your code acutally does not show the problem. But if you exchange TGraphError with TGraphAsymmError it reappers.

Here is the slightly modified example-code:

void example() {
TCanvas *c1 = new TCanvas(“c1”,“gerrors2”,200,10,700,500);
c1->DrawFrame(-0.4,0,1.2,12);

const Int_t n = 10;
Double_t x[] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
Double_t y[] = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
Double_t ex[] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
Double_t ey[] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
TGraphAsymmErrors *gr = new TGraphAsymmErrors(n,x,y,ex,ex, ey,ey);
gr->SetFillColor(kRed);
gr->SetMarkerColor(kBlue);
gr->SetFillStyle(3005);
gr->SetMarkerStyle(21);
gr->Draw(“e2ALP”);

TLegend *legend = new TLegend(0.15,0.75,0.30,0.85,"",“brNDC”);
legend->AddEntry(gr,“mygraph”,“flp”);
legend->Draw();
}

See you
Marc-Oliver

Marc-Oliver,

Thanks for the simple example. The problem is now fixed in CVS.

Rene