
// @(#)root/histpainter:$Id: TPaletteAxis.cxx 37541 2010-12-11 10:50:58Z couet $ // Author: Rene Brun 15/11/2002 /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #include "Riostream.h" #include "TROOT.h" #include "TPaletteAxis.h" #include "TVirtualPad.h" #include "TStyle.h" #include "TMath.h" #include "TView.h" #include "TH1.h" #include "TGaxis.h" ClassImp(TPaletteAxis) //______________________________________________________________________________ /* Begin_Html <center><h2>The palette painting class</h2></center> A <tt>TPaletteAxis</tt> object is used to display the color palette when drawing 2-d histograms. <p> The <tt>TPaletteAxis</tt> is automatically created drawn when drawing a 2-D histogram when the option "Z" is specified. <p> A <tt>TPaletteAxis</tt> object is added to the histogram list of functions and can be retrieved doing: <pre> TPaletteAxis *palette = (TPaletteAxis*)h->GetListOfFunctions()->FindObject("palette"); </pre> then the pointer <tt>palette</tt> can be used to change the pallette attributes. <p> Because the palette is created at painting time only, one must issue a: <pre> gPad->Update(); </pre> before retrieving the palette pointer in order to create the palette. The following macro gives an example. End_Html Begin_Macro(source) { TCanvas *c1 = new TCanvas("c1","c1",600,400); TH2F *h2 = new TH2F("h2","Example of a resized palette ",40,-4,4,40,-20,20); Float_t px, py; for (Int_t i = 0; i < 25000; i++) { gRandom->Rannor(px,py); h2->Fill(px,5*py); } gStyle->SetPalette(1); h2->Draw("COLZ"); gPad->Update(); TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette"); palette->SetY2NDC(0.7); return c1; }