Re: histogram fillstyle after reading

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Thu, 9 Feb 2006 16:36:41 +0100 (CET)

hi,
in your macro I put: hist1->SetFillStyle(1001); after the color setting and I get a filled histogram. I changed to any style and it is fine .. I do not see any problem. I am using root 5.09/01 on linux
olivier

On Thu, 9 Feb 2006, Gerhard Brandt wrote:

>
> hi,
>
> i've got a problem that seems very basic but i
> can't find the solution:
>
> does anyone have a working example of how to read
> a histogram from a file and change the style so it
> is filled? changing markers, linewidth etc. works
> but i can't get it filled.
>
> i am using ROOT 4.00.08 (in a brief scan of CVS messages in
> histpainter i saw no obvious fixes since then).
> macro below.
>
> thanks !
>
> gerhard
>
>
> {
>
> gROOT->Reset();
> gROOT->SetStyle("Plain");
> gStyle->SetHistFillStyle(1001);
> gStyle->SetHistFillColor(2);
> gROOT->ForceStyle();
>
> TCanvas *canv = new TCanvas("canv", "canvas", 800, 600);
> canv->UseCurrentStyle();
>
> TFile file1("histo.root");
>
> TIter keys(file1->GetListOfKeys());
> TKey* key;
> while ( key = (TKey*)(keys.Next()) ) {
>
> // Read histos
> if ( !strcmp(key->GetClassName(), "TH1F") ) {
> TString str(key->GetName());
>
> TH1F *hist1 = static_cast<TH1F*>(file1->Get(str));
> if ( !hist1 ) {
> cout << "Could not find "<<str<<" in "<<file1->GetName()<<endl;
> continue;
> }
> cout << str << endl;
>
> hist1->SetDirectory(0);
> hist1->SetFillColor(42);
>
> cout << hist1->GetFillColor() << endl;
> cout << hist1->GetFillStyle() << endl; // this prints 1001 allright
>
> hist1->Draw();
>
> }
> }
> }
>
>
>

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet_at_cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7670300
Received on Thu Feb 09 2006 - 16:36:47 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET