Graph with errors from RDataFrame

Hi!
I am new using RDataFrame and I would like to clarify two questions:

  1. Is there a way to get a graph with errors on the y-axis from a RDataFrame that contains x, y, and y-error in its columns? I have found examples with Graph but I would like to obtain a TGraphErrors for later fitting.
  2. Can I retrieve the maximum range of the dataframe?

Hi,
I am myself a rather inexperienced user, but in the RDataFrame Class reference is stated the function GraphAsymmErrors which has asymmetric errors, but these could be set to the same value to obtain your wanted result. As for the maximum range, I am not sure, what you mean. There is a function Max and Min which could give you the range of your data.
Hope this helps.
Cheers,
Emil

1 Like

Hi,
Thank you so much for your reply and for letting me know about the GraphAsymmErrors. Do you know how can I make the errors on x (exl, exh) to be zero? I don’t have errors on the x-axis and I don’t have any column in the dataframe for them.

I needed to get the total number of entries in the dataframe.
Thanks a lot!!
Lily

It seems that there is a problem with TGraphAsymmErrors from RDataFrame; ROOT says no member named 'GraphAsymmErrors' in 'ROOT::RDataFrame'.
Outside dataframe, you can just put zeroes where you want, e.g.

auto gr = new TGraphAsymmErrors(n,x,y,0,0,eyl,eyh);

but for RDataFrame the documentation says you should give a string (name of column), so if zero doesn’t work I suppose you could just use any column minus itself (e.g. TGraphAsymmErrors("x","y","x-x","x-x","eyl","eyh")), or define a column with that difference and use that column for zero errors.

1 Like

Hi,

I’m very late to the party, but just to clarify: GraphAsymmErrors is still unreleased: it’s present in the master branch (and therefore our nightly builds and it will be released with the upcoming ROOT v6.28.

In the meanwhile you might be able to emulate it by creating a TGraphAsymmErrors manually and passing it to RDataFrame’s Fill method.

Cheers,
Enrico

Thanks Enrico,

I found an example here ROOT: tutorials/dataframe/df005_fillAnyObject.C File Reference on how to use the Fill method but I could not figure out how to use it on TGraphErrors since I don’t find this class to expose a Fill method. But following this post Coloured scatterplot from TDataFrame - #2 by eguiraud I could make the TGraphErrors from the dataframe:

TGraphErrors* gtrue;

auto fillTrueValuesGraph = [&gtrue](int set, double y, double err_y){
      gtrue->SetPoint(gtrue->GetN(), set, y);
      gtrue->SetPointError( gtrue->GetN()-1, 0, err_y );
   };

df.Foreach(fillTrueValuesGraph, {"set", "y", "err_y"});