Re: [ROOT] TH1F: drawing option 'histe2' and TLegendEntry: Drawingoption 'lf'

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jul 16 2003 - 11:05:38 MEST


Hi Gero,

a workaround for this problem can be seen in your macro below

Rene Brun

{
  TH1* hist = new TH1F("hist", "hist", 5, 1, 10);
  hist->SetBinContent(2, 5.);
  hist->SetBinError(2, 1.5);
  hist->SetBinContent(3, 7.);
  hist->SetBinError(3, 1.);
  hist->SetBinContent(4, 6.8.);
  hist->SetBinError(4, .5);
  TH1 *hsave = (TH1F*)hist->Clone("hsave");
  hist->SetFillColor(kYellow);
  hist->Draw("e2");
  hsave->Draw("hist same][");
  TLegend * l = new TLegend(0.5, 0.9, .99,.99, "header");
  l->AddEntry(hist, "my hist", "flp");
  l->Draw();
}

Gero Flucke wrote:
> 
> Hi Rene,
> 
> On Tue, 15 Jul 2003, Rene Brun wrote:
> 
> > Hi Gero,
> >
> > Gero Flucke wrote:
> > >
> > > Hi ROOTers,
> > >
> > > 1)
> > > I tried to plot a 1D-histogram with an error band (option 'e2') AND with
> > > the line at the mean value. I tried
> > >
> > > hist->Draw("histe2")
> > >
> > > but the result is unsatisfactory, cf. script below,
> > > I can draw a white histogram with the lower error bounds on top of that,
> > > but that is quite annoying... :-(
> >
> > You should not use the option "hist" to get the error band. If you give this
> > option, you will get the normal error band AND also teh normal fill area of teh
> > histo.
> 
> Yes, that's the problem. But with
> 
> >  Just do:
> >   hist->Draw(" e2");
> >
> 
> I do NOT get the line at the central value (bin content) (but the marker
> that I am not interested in...).
> My aim is to have sth. like
> http://www-h1.desy.de/psfiles/figures/H1prelim-03-071.fig2a.eps
> 
> I tried some other draw option, but did not succeed.
> 
> Cheers
> 
>         Gero
> 
> > {
> >   TH1* hist = new TH1F("hist", "hist", 5, 1, 10);
> >   hist->SetBinContent(2, 5.);
> >   hist->SetBinError(2, 1.5);
> >   hist->SetBinContent(3, 7.);
> >   hist->SetBinError(3, 1.);
> >   hist->SetBinContent(4, 6.8.);
> >   hist->SetBinError(4, .5);
> >
> >   hist->SetFillColor(kYellow);
> >   hist->Draw("histe2");
> >   TLegend * l = new TLegend(0.5, 0.9, .99,.99, "header");
> >   l->AddEntry(hist, "my hist", "lf");
> >   l->Draw();
> > }
> >



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