Hi ROOTers!
I have a small macro where I’d like to set the TH2 color scheme. However, the number of colors appearing in the z-axis legend always appears to be the default value (20). Does anyone know if I’m doing something incorrect? Most of the code below is taken from ROOT documentation. I’m stumped.
My resulting pdf, which should have 100 colors, but which has 20:
canv.pdf (13.9 KB)
I’m sorry if this is well known or described elsewhere. I was unable to find other reports about this.
Thanks,
Alex
// run like:
// root -l -b -q test.C
void setColorScheme() {
UInt_t NColors = 100;
Double_t Red[] = {1.0, 0.0, 1.0, 1.0, 0.0};
Double_t Green[] = {1.0, 0.0, 0.0, 1.0, 0.0};
Double_t Blue[] = {1.0, 1.0, 0.0, 0.0, 0.0};
Double_t Length[] = {0.0, .25, .50, .75, 1.0};
TColor::CreateGradientColorTable(5, Length, Red, Green, Blue, NColors);
}
void test() {
gROOT->SetBatch(true);
gStyle->SetOptStat(0);
setColorScheme();
auto canv = std::make_unique<TCanvas>("canv", "canv", 800, 800);
auto empty = std::make_unique<TH2D>("empty", ";x;y;z", 10, 0, 100, 10, 0, 100);
empty->Fill(10, 10);
canv->Draw();
empty->Draw("colzsame");
canv->Print("canv.pdf", "pdf");
}
ROOT Version: 6.26/06 and 6.26/08
Platform: macosx64 and linuxx8664gcc