Home > Back-end >  ROOT(CERN): Plot an figure with error bars using data from an csv file
ROOT(CERN): Plot an figure with error bars using data from an csv file

Time:05-18

I'm trying to read data from a .csv file, which contains 4 columns: "x","y","Standard Deviation" and "Uncertainty". I want to plot a scatter diagram with error bars, which represent the uncertainty red from the .csv file. I run the following codes in root's REPL:

auto rdf = ROOT::RDF::MakeCsvDataFrame("./file.csv")
auto g1 = rdf.GraphAsymmErrors("x","y","","","Uncertainty","Uncertainty");

but I get an error:

ROOT_prompt_1:1:15: error: no member named 'GraphAsymmErrors' in 'ROOT::RDataFrame'

Meanwhile I can run the code below correctly:

auto g2=rdf.Graph("x","y");
g2->SetMarkerStyle(6);
g2->Draw();

, which confuses me because in the document of ROOT, the Graph() method and GraphAsymmErrors() method both seem to be the method of RDataFrame, so I think it should not show the error above.

Also, my root's version is 6.26, installed on Ubuntu 22.04 via snap.

CodePudding user response:

GraphAsymmErrors doesn't seem to exist in the v6.26 documentation. The documentation you linked was for the master branch. You'll probably have to update to a nightly-build or wait for the next release in order to use that function.

In the meantime I would recommend you use RDataFrame::Take() on the respective branches to get them as std::vectors, and use the TGraphAsymmErrors constructor directly.

  • Related