Facing problem when trying to add error-bars in a multigraph. graphs are plotted using data file

Facing problem when trying to add error-bars in a multigraph. graphs are plotted using data file

Hi Bijan,

Welcome to the ROOT Community!

Could you perhaps give us a bit more details about the problem you are facing?

Best,
D

Hello sir ,
thank you for the response

Actually i want to draw some plot in a graph specifically multigraph. when i plotted without the errorbar then it is properly plotted. and also when i am drawing the eroor bar curves in another canvas then it is working. but when i am plotting all in same graph then it will not working . i have also attched some snapshot for understanding the problem



Hi,

Can you share a minimalc++ or Python reproducer of the problem?

Cheers,
D

void xsection2()
 {
 TMultiGraph *mg = new TMultiGraph();
 
 TGraph *gr1 = new TGraph();
 gr1->SetMarkerStyle(kFullCircle);
 
 gr1->SetLineColor(kPink+10);
 gr1->SetLineStyle(5);
 gr1->SetLineWidth(2);
 
 fstream file;
 file.open("rp031068omp1.txt", ios::in);
 
 while(1)
 {
   double x,y;
   file >> x >> y;
 gr1->SetPoint(gr1->GetN(), x, y);
 if(file.eof())break;
 }
 
 file.close();
 file.open("levkovski_et_al_91_cu_n.txt", ios::in);
 TGraphErrors *gr10 = new TGraphErrors();
 //gr10->SetLineColor(4);
 //gr10->SetMarkerStyle(33);
 double x,y,ex,ey;
 
 while(1)
 {
   file >> x >> y >> ex >>ey;
 gr10->SetPoint(gr10->GetN(), x, y);
 gr10->SetPointError(gr10->GetN(),ex, ey );
 
 if(file.eof()) break;
 }
 
 file.close();

 TCanvas *c1= new TCanvas();
mg->Add(gr1);

mg->Add(gr10);
mg->Draw("AC");
}

use any txt file for plotting

Hi,

I really would like to have your original txt if possible, to be able to reproduce the issue (if any) you are confronted with.

D

as i am new user , i am unable to upload any txt file , show some error occurred

gr10->SetPointError(gr10->GetN() - 1, ex, ey );

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