Re: [ROOT] saving palette colors

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Mar 14 2003 - 12:52:56 MET


Hi Vadim,

see: http://root.cern.ch/root/roottalk/roottalk03/0796.html

Rene Brun

Khotilovich Vadim wrote:
> 
> Hi,
> 
> I'm trying to find the way to save the palette information with a
> colz-histogram into the root file (see the code below). When I open the file
> I see that the number of contours gets saved, but the colors are different.
> Also when I even just move something with mouse on the histogram that just
> was drawn I loose my colors too. I tried it in two versions: 3.03/06 and
> 3.05/00 from Fermi build. In 3.05/00 I also have the errors like that:
> root [0]
> Attaching file hsimple.root...
> Warning in <TClass::TClass>: no dictionary for class TPaletteAxis is available
> root [1]
> root [1] TBrowser b
> root [2] Error in <TBuffer::CheckByteCount>: object of class TPaletteAxis read
> too few bytes: 17 instead of 311
> Warning in <TBuffer::CheckByteCount>: TPaletteAxis::Streamer() not in sync
> with data on file, fix Streamer()
> Error in <TBuffer::CheckByteCount>: object of class TPaletteAxis read too few
> bytes: 4 instead of 298
> Warning in <TBuffer::CheckByteCount>: TPaletteAxis::Streamer() not in sync
> with data on file, fix Streamer()
> 
> and also I see that the statistics box appears behind the palette then.
> 
> One more question:
> in a simple setting, like in the example below, I managed to learn how to save
> the statistics boxes style settings in a file, but in a more complex system
> (the CDF online monitoring software) sometimes I can't figure out why it is
> not working (also SetContour(7) doesn't work for me there). So the question
> is: is there anything more I should know other then a) create histograms
> after setting the style, b) update canvas after drawing them?
> 
> regards,
> Vadim
> 
> file try.C:
> -----------------------------------------------------
> void setStyle(TStyle *st){
>   st->SetOptStat(1110);
>   st->SetStatColor(0);
>   st->SetTitleColor(0);
>   st->SetTitleW(0.57);
>   st->SetCanvasBorderMode(0);
>   st->SetFrameBorderMode(0);
>   st->SetCanvasColor(0);
> }
> 
> void try (){
>   TList *l = new TList();
> 
>   TStyle *myStyle = new TStyle("xx","xx");
>   setStyle(myStyle);
>   TStyle *ssave = gStyle;
>   myStyle->cd();
> 
>   TFile* hfile = new TFile("hsimple.root","RECREATE");
> 
>   int colours[]={1,12,28,39,47,3,5};
>   gStyle->SetOptStat(1110);
> //  gROOT->ForceStyle();
> 
>   TH2F *hist = new TH2F("Gaussian","Gaussian",10,-10,10,10,-10,10);
>   TH2F *histb = new TH2F("GaussianB","GaussianB",20,-10,10,20,-10,10);
>   gRandom->SetSeed();
>   for (Int_t i = 0; i < 10000; i++){
>     hist->Fill(gRandom->Gaus(0,5),gRandom->Gaus(0,5));
>     histb->Fill(gRandom->Gaus(0,6),gRandom->Gaus(0,4));
>   }
> 
>   TCanvas *c1 = new TCanvas("c1","c1",600,800);
>   c1->Divide(1,2);
>   c1->cd(1);
>   hist->SetContour(7);
>   gStyle->SetPalette(7,colours);
> //  gROOT->ForceStyle();
>   hist->Draw("colz");
>   gPad->Update();
>   c1->cd(2);
>   gStyle->SetOptStat(10);
>   histb->SetContour(7);
>   gStyle->SetPalette(7,colours);
>   histb->Draw("colz");
>   c1->Modified();c1->Update();
> 
>   gStyle = ssave;
> 
>   l->Add(c1);
>   l->Write();
>   hfile->Write();
> }



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET