Stack scatter plots (TH2)


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Dear ROOT users,

I have a data set stored into a tree from which I make a scatter plot, weighted by a specific quantity. I’d like to stack this onto another scatter plot, which derives from another data set which I have stored in another tree. Is there a method to stack two plots together, with ROOT deciding the upper and lower bins automatically?

The only place I can think of to start from is creating histograms from the two data sets, then somehow use THStack to Add the histograms to this. I’d like to know if I’m on the right track, and if so, how I should progress. If this is completely incorrect, could somebody please advise me on how to handle two data sets in two separate trees, with the aim of making comparisons between the two sets of data?

Thanks in advance!

Can’t you just simply do:

h1.Draw()
h2.Draw('same') 

?

If I remember correctly there is no issue with having different binnings.

1 Like

See what is drawn in pad3 in this example

   //
   // Display a scatter plot of two columns with a selection.
   // Superimpose the result of another cut with a different marker color
   pad3->cd();
   pad3->GetFrame()->SetBorderSize(8);
   ntuple->SetMarkerColor(1);
   ntuple->Draw("py:px","pz>1");
   ntuple->SetMarkerColor(2);
   ntuple->Draw("py:px","pz<1","same");
1 Like

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