How to set different width for error bars and data line in TGraphErrors

ROOT Version: 6.24

Hi, can you please explain a bit more what your question is? What do you mean by “data line” in TGraphErrors? Maybe you can show us what code you already have, then it’s easiest to tell you what the necessary changes are.

Hi Jonas, thanks for the reply. This is my first time asking something in forum so I really don’t know the proper way. I’ll explain myself in better way. Here is my code

{
	
	TCanvas *c1 = new TCanvas("c1", "c1", 994, 999);	
	
	TGraphErrors *g1 = new TGraphErrors("name of my file", "%lg %lg %lg");
	g1->SetLineColor(kBlack);
	g1->SetLineWidth(3);  
    g1->Draw("AC");

    gStyle->SetEndErrorSize(0);

}

As you can see from > g1->Draw("AC"); I’m drawing a curve. You can also find g1->SetLineWidth(3); which affects both my normal curve line and error bar line for g1 plot. Can I plot error bar line with linewidth of 1 and normal curve line of linewidth of 4??

{
   Double_t x[5]  = {1,2,3,4,5};
   Double_t y[5]  = {5,4,3,2,1};
   Double_t ex[5] = {1,1,1,1,1};
   Double_t ey[5] = {500,400,300,200,100};
   TGraphErrors *ge = new TGraphErrors(5,x,y,ex,ey);
   for (int i=0; i<5; i++) {
   Double_t nex = ge->GetErrorX(i);
   Double_t ney = ge->GetErrorY(i)/100.;
   ge->SetPointError(i,nex,ney);
   }
   ge->SetLineWidth(5);
   ge->Draw("Ap");
   TGraphErrors * gec = (TGraphErrors * )ge->Clone();
   gec->Draw("C");
   gec ->SetLineWidth(1);
}
1 Like

Thank you so much couet!!! Nice trick you’ve done there. Helped me a lot appreciated it buddy

1 Like

Hi!! Is there any way it can be other way around mean curve which is drawn must have a width of 4 and error bars of width 1

{
{
   Double_t x[5]  = {1,2,3,4,5};
   Double_t y[5]  = {1,2,3,2,1};
   Double_t ex[5] = {1,1,1,1,1};
   Double_t ey[5] = {1,2,3,2,1};
   Double_t nex, ney;
   auto ge = new TGraphErrors(5,x,y,ex,ey);
   auto gc = new TGraph(5,x,y);
   ge->SetLineWidth(1);
   ge->Draw("Ap");
   gc ->SetLineWidth(4);
   gc->Draw("C");
}