#include #include #include #include using namespace std; void paleta() { //palette settings - completely independent const Int_t NRGBs = 6; const Int_t NCont = 999; Double_t stops[NRGBs] = { 0.00, 0.1, 0.34, 0.61, 0.84, 1.00 }; Double_t red[NRGBs] = { 0.99, 0.0, 0.00, 0.87, 1.00, 0.51 }; Double_t green[NRGBs] = { 0.00, 0.0, 0.81, 1.00, 0.20, 0.00 }; Double_t blue[NRGBs] = { 0.99, 0.0, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); gStyle->SetOptStat(0); //here the actually interesting code starts const Double_t min = 0.9; const Double_t max = 1.1; const Int_t nLevels = 999; Double_t levels[nLevels]; for(int i = 1; i < nLevels; i++) { levels[i] = min + (max - min) / (nLevels - 1) * (i); } levels[0] = 0.01; // levels[0] = -1; //Interesting, but this also works as I want! TCanvas * c = new TCanvas(); TH2D *h = new TH2D("h", "", 10, 0, 10, 10, 0, 10); h->SetContour((sizeof(levels)/sizeof(Double_t)), levels); h->SetBinContent(5, 7, 1.20); h->SetBinContent(5, 6, 1.05); h->SetBinContent(5, 5, 1.00); h->SetBinContent(5, 4, 0.95); h->SetBinContent(5, 3, 0.80); h->DrawClone("col text");// draw "axes", "contents", "statistics box" h->GetZaxis()->SetRangeUser(min, max); // ... set the range ... h->Draw("z same"); // draw the "color palette" c->SaveAs("c.png"); }