SetMarkerStyle in TH2F with new ROOT version

Hello experts,

I had recently needed to change the root version from ROOT 6.24/08 to ROOT 6.30/06.

Since then, the old script I had to draw a 2D histogram and apply on it the SetMarkerStyle or SetMarkerColor, is not working anymore.

The old script snippet:

TTree *t  = new TTree ();
 _file0->GetObject("mytree", t);

TH2F* h = new TH2F("h","h",100,0,1,100,2,4);
t->Draw("var1:var2>>h");

h->SetMarkerStyle(29);
h->SetMarkerColor(1);
h->Draw("hist");
h->SaveAs(h.root);

trying also h->Draw(“P”); that works in 1D didn’t work here.

What have changed?

Many thanks in advance for your help :slight_smile:

Hi,

Adding in the loop @couet . In the mean time, what do you expect and what do you get?

Cheers,
D

The SCAT option is not the default anymore. It was a misleading option. It was not a real scatter plot as markers were drawn randomly in the bins. This number of marker drawn in each bin was proportional to the bin content. Now the default option for 2D histograms is COL (all this is documentated in the recent versions of the reference guide). If nevertheless if you still what to get this misleading plot you can activate it using option SCAT. In parallel ROOT now provide real scatter plots with the class TScatter.

Hello,

Thank you both :slight_smile:

@Danilo, instead of getting full starts in purple colors, I just got a pixelled blue/yellow histogram.

@couet with the SCAT option it solved the issue, in case someone else will look for this, this is what I did:
h->Draw(“hist SCAT”);

But knowing now that this is not the correction way to draw such a histogram, I assume you refer to this:

I will try it out.

Thanks again!

See also: ROOT: THistPainter Class Reference

Seems to me you simply better do:

h->Draw();

And the a nice heat map (color plot).

Thanks, but then I get as you said the heat color map, and I need the symbols and colors because in reality I plot signal sample and background samples in one canvas and I need to distinguish between their scatterings.

BTW, from the repeated warnings I keep getting while trying to edit the plots:
“Warning in THistPainter::MakeChopt: option SCAT is deprecated.”
I understand that this will be gone soon. Also, it makes the root even locally super slow :confused:

In that case do only:

t->Draw("var1:var2>>h");

This will give you a real scatter plot.
or simply (if the automatic scales are ok for you):

t->Draw("var1:var2");