Color different set of data in same histogram

How does one color different points in a 2d histogram? Say one has a set of points (x,y) that one fills the histogram with, and another set of points (u,v)? Thanks!

Depends on the plotting options you use (see https://root.cern.ch/doc/master/classTHistPainter.html).
For “scat” you can do, for instance:

  h1->SetMarkerColor(kRed);
  h2->SetMarkerColor(kBlue);
  // ...
  h1->Draw("scat");
  h2->Draw("same,scat");

For “arr” (arrow) you would use SetLineColor instead, etc.
Another option, if you don’t need to bin the data, is use two TGraphs, one for (x,y), one for (u,v), set the marker colors and plot as TMultiGraph.

1 Like

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