#include "TCanvas.h" #include "TH2F.h" #include "TStyle.h" int prettyPalette(int maxPretty=500) { // mostly ripped from TColor.cxx Float_t saturation = 1; Float_t lightness = 0.5; Float_t maxHue = 240; Float_t minHue = 0; //Int_t maxPretty = 500; Float_t hue; Float_t r, g, b, h, l, s; Int_t i; UInt_t g2, c; UInt_t nPalette = 0; Int_t *palette = new Int_t[maxPretty+1]; TColor *color; Int_t highestIndex = 0; TSeqCollection *colorTable = gROOT->GetListOfColors(); if ((color = (TColor *) colorTable->Last()) != 0) { if (color->GetNumber() > highestIndex) { highestIndex = color->GetNumber(); } while ((color = (TColor *) (colorTable->Before(color))) != 0) { if (color->GetNumber() > highestIndex) { highestIndex = color->GetNumber(); } } } int start = ++highestIndex; for (i=0 ; iSetPalette(nPalette, palette); delete[] palette; return start; } void colors() { gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gStyle->SetOptFit(0); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetMarkerSize(.1); gStyle->SetMarkerStyle(8); gStyle->SetGridStyle(3); gStyle->SetPaperSize(TStyle::kA4); gStyle->SetStatW(0.25); gStyle->SetStatFormat("6.4g"); gStyle->SetColorModelPS(0); prettyPalette(); TSeqCollection *colorTable = gROOT->GetListOfColors(); TColor* color = 0; if ((color = (TColor *) colorTable->Last()) != 0) { do { printf("color: %i hue: %f\n", color->GetNumber(), color->GetHue()); } while ((color = (TColor *) (colorTable->Before(color))) != 0); } TH2F *h = new TH2F("h", "test", 50, -10, 10, 50, -10, 10); h->FillRandom("gaus", 10000); printf("z bins: %i\n", h->GetNbinsZ()); TCanvas* cv = new TCanvas("cv", "", 1000, 1000); h->Draw("colz"); cv->SaveAs("test.svg"); delete cv; delete h; }