Transparency for TH1D on TCanvas

Hi all,

I’m trying to plot several TH1D on the same TCanvas and I’d like some to be “a little” transparent to see if there is not something behind it. In the following “hd” and “hbb” are TH1D* and I want hd to be plotted with markers.


if (hd->GetMaximum() > hbb->GetMaximum()){
hd->Draw(“p”);
hbb->Draw(“samehist”);
}
else{
hbb->Draw();
hd->Draw(“samep”);
}

hbb->SetFillColor(7);
hbb->SetFillStyle(4050);

From
root.cern.ch/cgi-bin/print_hit_b … ml?attfill
I see :
Conventions for fill styles:
0 : hollow
1001 : Solid
2001 : hatch style
3000+pattern_number (see below)
4000 :the window is transparent.
4000 to 4100 the window is 100% transparent to 100% opaque

So I tried several values for the argument of TH1::SetFillStyle() between 4000 and 4100 but hbb histogram is never transparent. Any idea of what I’m doing wrong ?
I use root v4_00_04.

Thanks,

 Vincent

Example:

{
  c1 = new TCanvas("c1","Transparent histograms",200,10,700,500); 
  c1->SetFillColor(42);
  c1->GetFrame()->SetFillColor(21);
  c1->GetFrame()->SetBorderSize(6);
  c1->GetFrame()->SetBorderMode(-1);

  hpx = new TH1F("hpx","This is the px distribution",100,-4,4);   
  hpy = new TH1F("hpy","This is the py distribution",100,-4,4);   

//  Set canvas/frame attributes (save old attributes)
  hpx->SetFillColor(48);
  hpy->SetFillColor(47);  
  hpy->SetFillStyle(3001);

// Fill histograms randomly
  gRandom->SetSeed();
  Float_t px, py, pz;
  const Int_t kUPDATE = 1000;
  for (Int_t i = 0; i < 25000; i++) {
     gRandom->Rannor(px,py);
     Float_t random = gRandom->Rndm(1);
     hpx->Fill(px);
     hpy->Fill(3+py);
  }

// Save all objects in this file
  hpx->Draw();
  hpy->Draw("same");
}