Histrograms Style

Dear Rooters,

I’m doing some histograms with ROOT. I’ used to do them with PAW before and there was a style (htyp 244) which produced a filled area instead of the error bars.

In ROOT I manage to do something similar with:

but I don’t manage to draw also a contour around the filled area like the PAW style did it.

Moreover it would be nice to add also a curve through the bins. In other words make some kind of mixture between the two draw options “C” and “E4”. By making

h1->Draw("CE4")

I only get the filled area with some black Marker in between.

Anybody knows how to do this?

Thank you very much and best wishes,

Gionata

The hatches work for histograms. Try this macro:

{
  TCanvas *c1 = new TCanvas("c1","c1",800,600);
  TH1F *h1 = new TH1F("h1","Histo 1",100,-5,5);
  h1->FillRandom("gaus",10000);
  h1->SetFillStyle(3244);
  h1->SetFillColor(1);
  h1->Draw();
}

see also: root.cern.ch/root/html/TAttFill.html#F2

Thanks for answering.

What you suggest works, but adding error bars the hatches disappear. I tried for example this:

[code]Double_t random;

TCanvas *c1 = new TCanvas(“c1”,“c1”,800,600);
TH1F *h1 = new TH1F(“h1”,“Histo 1”,100,-5,5);
h1->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h1->SetBinError(i,random);
}

h1->SetFillStyle(3244);
h1->SetFillColor(1);
h1->Draw(“E4”);[/code]

I get the hatches with your example


Sorry, what I meant is that the shaded area is not bounded like for example in the lowest plot on the left of this example:

http://paw.web.cern.ch/paw/tutorial/tut032.html

Ah yes. That’s not as straight forward. The way I found was to add::

TH1F *h2 = h1->DrawClone("E4 SAME");
h2->SetFillStyle(0);

at the end of your macro.

Thank you very much.

In the example macro this works exactly as expected. In the original plots I have still some difficulties, but I hope to fix them.

Best regards,

Gionata

It’s again me.

Apparently your suggestion does not work for more than one histogram. In the following example only one histogram in bounded:

[code]TCanvas *c1 = new TCanvas(“c1”,“c1”,800,600);

TH1D *h1 = new TH1D(“h1”,“Histo 1”,100,-5,5);
h1->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h1->SetBinError(i,random);
}
h1->SetFillStyle(3444);
h1->SetFillColor(kRed);
h1->Draw(“E4”);
TH1D *hi1 = h1->DrawClone(“E4 SAME”);
hi1->SetFillStyle(0);

TH1D *h2 = new TH1D(“h2”,“Histo 2”,100,-5,5);
h2->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h2->SetBinError(i,random);
}
h2->SetFillStyle(3244);
h2->SetFillColor(kBlue);
h2->Draw(“E4 SAME”);
TH1D *hi2 = h2->DrawClone(“E4 SAME”);
hi2->SetFillStyle(0);
[/code]

Am I doing something wrong or is there another trick?

I have no idea (yet) why, but if you do it that way it is ok:

{
   TCanvas *c1 = new TCanvas("c1","c1",800,600);

   TH1D *h1 = new TH1D("h1","Histo 1",100,-5,5);
   h1->FillRandom("gaus",10000);

   for(Int_t i=1;i<100;i++){
      random = 10.0*gRandom->Rndm();
      h1->SetBinError(i,random);
   }
   h1->SetFillStyle(3444);
   h1->SetFillColor(kRed);
   h1->Draw("E4");
   TH1D *hi1 = h1->DrawClone("E4 SAME");
   hi1->SetFillStyle(0);


   TH1D *h2 = new TH1D("h2","Histo 2",100,-5,5);
   h2->FillRandom("gaus",10000);

   for(Int_t i=1;i<100;i++){
      random = 10.0*gRandom->Rndm();
      h2->SetBinError(i,random);
   }
   h2->SetFillStyle(0);   
   h2->SetFillColor(kBlue);
   h2->Draw("E4 SAME");
   TH1D *hi2 = h2->DrawClone("E4 SAME");
   hi2->SetFillStyle(3244);
}

Hello,

sorry for not answering. I was away for a while.

Thank you very much for the suggestion on how to plot two histogram with this style.
It seems a bit stupid, but actually I need to plot three of them and I do not manage to get them using any of the two methods.

can you send the macro having problems ?

Of course, sorry:
Here is an example

[code]gROOT->Reset();

Double_t random;

TCanvas *c1 = new TCanvas(“c1”,“c1”,800,600);

TH1D *h1 = new TH1D(“h1”,“Histo 1”,100,-5,5);
h1->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h1->SetBinError(i,random);
}
h1->SetFillStyle(3444);
h1->SetFillColor(kRed);
h1->Draw(“E4”);
TH1D *hi1 = h1->DrawClone(“E4 SAME”);
hi1->SetFillStyle(0);

TH1D *h2 = new TH1D(“h2”,“Histo 2”,100,-5,5);
h2->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h2->SetBinError(i,random);
}
h2->SetFillStyle(0);
h2->SetFillColor(kBlue);
h2->Draw(“E4 SAME”);
TH1D *hi2 = h2->DrawClone(“E4 SAME”);
hi2->SetFillStyle(3244);

TH1D *h3 = new TH1D(“h3”,“Histo 3”,100,-5,5);
h3->FillRandom(“gaus”,10000);

for(Int_t i=1;i<100;i++){
random = 10.0*gRandom->Rndm();
h3->SetBinError(i,random);
}
h3->SetFillStyle(3244);
h3->SetFillColor(kGreen);
h3->Draw(“E4 SAME”);
TH1D *hi3 = h3->DrawClone(“E4 SAME”);
hi3->SetFillStyle(0);
[/code]

The third histogram, the green one, is not bounded.

{

   Double_t random;

   TCanvas *c1 = new TCanvas("c1","c1",800,600);

   TH1D *h1 = new TH1D("h1","Histo 1",100,-5,5);
   h1->FillRandom("gaus",10000);
   for(Int_t i=1;i<100;i++){
      random = 10.0*gRandom->Rndm();
      h1->SetBinError(i,random);
   }
   h1->SetFillStyle(3444);
   h1->SetFillColor(kRed);

   TH1D *h2 = new TH1D("h2","Histo 2",100,-5,5);
   h2->FillRandom("gaus",10000);
   for (Int_t i=1;i<100;i++) {
      random = 10.0*gRandom->Rndm();
      h2->SetBinError(i,random);
   }
   h2->SetFillStyle(3244);
   h2->SetFillColor(kBlue);

   TH1D *h3 = new TH1D("h3","Histo 3",100,-5,5);
   h3->FillRandom("gaus",10000);
   for(Int_t i=1;i<100;i++){
      random = 10.0*gRandom->Rndm();
      h3->SetBinError(i,random);
   }
   h3->SetFillStyle(3244);  
   h3->SetFillColor(kGreen);

   TH1D *hi1 = h1->DrawClone("E4 ");    
   hi1->SetFillStyle(0);
   TH1D *hi3 = h3->DrawClone("E4 SAME");
   hi3->SetFillStyle(0);
   TH1D *hi2 = h2->DrawClone("E4 SAME");
   hi2->SetFillStyle(0);
   h1->Draw("E4 SAME");
   h2->Draw("E4 SAME");
   h3->Draw("E4 SAME");
}

Thank you very much!