-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Check duplicate issues.
- Checked for duplicates
Description
When drawing a TScatter plot as a temperature map, and setting (zooming) a symmetric Z range between -max and +max, the background of the underlying is painted (without asking for it, since it defaults to COLZ and COLZ only draws zeroes if there are negatives, unlike COL1) with the background color corresponding to the empty bin content 0.
However, there is slight bias, the background color does not match exactly 0 but is rather 5% off. I checked that with Inkscape opening the PDF. I highlighted in red the matching colors of the palette and the hist.
(This is a slightly concerning since it silently shows biased background color.)
Reproducer
void sc()
{
auto canvas = new TCanvas();
canvas->SetRightMargin(0.14);
gStyle->SetPalette(kLightTemperature);
const int n = 3;
double x1[n] = {30,40,35};
double y1[n] = {60,70,65};
double c1[n] = {100, -100,0};
double s1[n] = {1, 1, 1};
auto scatter1 = new TScatter(n, x1, y1, c1, s1);
scatter1->SetMarkerStyle(20);
scatter1->SetTitle("Scatter plot title;X title;Y title;Z title");
scatter1->GetXaxis()->SetRangeUser(20.,90.);
scatter1->GetYaxis()->SetRangeUser(55.,90.);
scatter1->GetZaxis()->SetRangeUser(-150.,150.);
scatter1->Draw("A");
canvas->SaveAs("sc.pdf");
}
The issue seems to come from this line in THistPainter:
Int_t theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
in conjunction with the fact that the TScatter palette defines 255 colors but the underlying histogram has only 20 colors (default).
So calling gStyle->SetNumberContours(255); in advance is a workaround to avoid this issue.
But still, I guess that either
- background painting with TScatter should be removed (or an opt-out behavior when passing SKIPBACK0 as draw option)
- or TScatter should automatically set the number of contours to match the ones of the underlying hist.
ROOT version
ROOT v6.37.99
Built for linuxx8664gcc on Nov 06 2025, 10:58:41
From tags/v6-38-00-rc1@v6-38-00-rc1
With c++ (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0 std201703
Binary directory: /tmp/root/bin
Installation method
Binary Release Download 6.38rc1
Operating system
Ubuntu 22.04
Additional context
No response