#include "TH2D.h" #include "TCanvas.h" #include "TStyle.h" #include "TExec.h" #include "TPad.h" #include "TRandom.h" #include "TPaletteAxis.h" #include "TList.h" #include "TColor.h" void BPalette() { Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0}; Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0}; Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0}; Double_t stop[] = {0., .25, .50, .75, 1.0}; TColor::CreateGradientColorTable(5, stop, r, g, b, 100); } void GrayPalette() { Double_t r[] = {0., 1.}; Double_t g[] = {0., 1.}; Double_t b[] = {0., 1.}; Double_t stop[] = {0., 1.}; TColor::CreateGradientColorTable(2, stop, r, g, b, 100); } void GrayInvPalette() { Double_t r[] = {1., 0.}; Double_t g[] = {1., 0.}; Double_t b[] = {1., 0.}; Double_t stop[] = {0., 1.}; TColor::CreateGradientColorTable(2, stop, r, g, b, 100); } void color() { gStyle->SetOptStat(0); TCanvas* can = new TCanvas("can", "can", 400, 600); can->Divide(2, 3, 1e-10, 1e-10); TH2D* hist = new TH2D("hist", "", 100, -5, 5, 100, -5, 5); hist->SetContour(100); for(int i = 0; i < 100000; i++){ double x = gRandom->Gaus(); double y = gRandom->Gaus(); hist->Fill(x, y); } // i TExec* exe[6]; exe[0] = new TExec("ex0", "gStyle->SetPalette(0);"); exe[1] = new TExec("ex1", "gStyle->SetPalette(1);"); exe[2] = new TExec("ex2", "GrayPalette();"); exe[3] = new TExec("ex3", "GrayInvPalette();"); exe[4] = new TExec("ex4", "BPalette();"); exe[5] = new TExec("ex5", "BPalette();"); for(int i = 0; i < 6; i++){ can->cd(i + 1); hist->Draw("axis z"); if(i == 5){ TPaletteAxis* palette = (TPaletteAxis*)hist->GetListOfFunctions()->FindObject("palette"); Int_t col = palette->GetValueColor(0.); gPad->SetFrameFillColor(col); } // if gPad->Update(); exe[i]->Draw(); hist->Draw("same colz"); gPad->Update(); } // i }