Re: [ROOT] Fill patterns and superimposed histograms

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Thu Oct 03 2002 - 17:52:46 MEST


 Hi,

 This is how patterns works. And I guess that is how should be if one
wants to mix patterns (for example hatches in some direction superimposed
with hatches in some other direction). If you want to have a solid
background for your smaller histogram, plot it first as filled (with your
preferred colour) and then plot it again with the pattern you want.

 Cheers,      O.Couet

--
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                                    
E-Mail: Olivier.Couet@cern.ch                      Phone: +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/              Fax:   +41 22 7677155

On Thu, 3 Oct 2002, Jochen Cammin wrote:

> Dear ROOTers,
> 
> I would like to draw two histograms superimposed with different fill 
> patterns (either using a THStack or just with the help of Draw("same").
> 
> This is illustrated with the small macro below.
> 
> One histogram should be printed with FillStyle 3004 and the other one with 
> 3005. The problem, however, is that the 'smaller' histogram seems to be 
> transparent so that the resulting pattern is the overlay of pattern 3004 
> and 3005. This is the same on screen, in the postscript and on the 
> printout. I tried to set the transparency with FillStyle 4100, but this has 
> no effect at all.
> 
> How can I make the 'smaller' histogram being opaque?
> 
> [I am using the CVS Version on RH 7.2.1]
> 
> Regards,
>    Jochen
> 
> {
> gROOT->Reset();
> TH1F *h1 = new TH1F("h1","Histo 1",100,-3,3);
> h1->FillRandom("gaus",10000);
> TH1F *h2 = new TH1F("h2","Histo 2",100,-3,3);
> h2->FillRandom("gaus",20000);
> 
> h1->SetFillStyle(3004);
> h1->SetFillColor(1);
> h2->SetFillStyle(3005);
> h2->SetFillColor(1);
> 
> THStack *hs = new THStack("hs","A stack of histograms");
> hs->Add(h1);
> hs->Add(h2);
> 
> // Use this ...
> hs->Draw();
> // ... or this
> //h2->Draw();
> //h1->Draw("same");
> 
> // c1->Print("test.ps"); // uncomment to generate a postscript file
> }
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET