Plotting two scatter plots

Hi there,

I’m trying to create two sets of plots, showing raw and filtered data for the same two TTrees, but am running into an error when trying to plot the two filtered graphs on top of each other.

No matter where I seem to put the “same” argument in the second graph, it says the fourth argument should be a Long64_t, and doesn’t accept any of the other arguments.

Any help would be greatly appreciated.

TCanvas *cf = new TCanvas("cf","Raw Data");

f1avg = TMath::Mean(f1->GetSelectedRows(),f1->GetV1());
f2avg = TMath::Mean(f2->GetSelectedRows(),f2->GetV1());

TCanvas *c1 = new TCanvas("c1","Plot One");
f1->Draw("f.v:f.t","",TString::Format("f.v < (%lf*1.5) && f.v > 0",f1avg));
f2->Draw("f.v:f.t","",TString::Format("f.v < (%lf*1.5) && f.v > 0",f2avg),"same");


_ROOT Version: 6.12
_Platform: Scientific Linux
_Compiler: gcc

The drawing option is the 3rd parameter.

You should do:

f1->Draw("f.v:f.t",TString::Format("f.v < (%lf*1.5) && f.v > 0",f1avg));
f2->Draw("f.v:f.t",TString::Format("f.v < (%lf*1.5) && f.v > 0",f2avg),"same");
1 Like

Thanks, changed my code to match yours, however it is still only displaying the second graph, just with no errors - Do I need to put “same” on both?

is the range of the 2nd plot included in the range of the 1st one ?

The second plot is has the same number of points, but is slightly higher up the same scale, however I’m writing a generic macro for lots of uses, so it won’t always be the case.

The 2nd plot will not change the range of the 1st one. So if the 2nd plot has a different range you will not see it. If the two ranges are different you should first use gPAd->DrawFrame to draw a frame with a range including both plots and then you draw the two plots with the option “same”

1 Like

Thanks for this; is there an easy way to determine the maximum and minimum points on the x- and y- axes, in order to provide DrawFrame with the dimensions?

1 Like

Sorry to keep rehashing this, but I’m struggling to work out how to define the columnname required; I have two events e1 and e2, each containing one branch f, which contains two leaves ‘v’ and ‘t’. Usually calling f.v and f.t gets the desired result, but neither this nor e1->f.v is accepted for this function, with the first option stating it is an “undeclared identifier”, and the second apparently being of type Double_t, when const char * is required.

May be you can get the value like in this example and get the min and max of the returned vectors ?

I’m afraid the data I have contains around 300,000 points of data which changes with every event, so I’m unsure of where my maximum would be! GetMaximum is a useful tool, but I’m afraid I don’t know how to use it

I do not have more infos than what is in the manual.

Sure, thanks for your help!

It spontaneously started working without any form of frame; one of the miracles of quitting and restarting Root, methinks! :grin:

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