Re: [ROOT] rotation of 1D histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jun 21 2000 - 16:18:01 MEST


Hi Hiroki,

This option does not exists by default, but is not too complicated
to emulate. Here is an example.

Rene Brun


void bars()
{
   // example showing how to plot a 1-d histograms horizontal
   
   Int_t nbins  = 20;
   Float_t xmin = -4;
   Float_t xmax =  4;
   TH1F *h = new TH1F("h","h horiz",nbins,xmin,xmax);
   h->FillRandom("gaus",1000);
   h->SetFillColor(kRed);
      
   Float_t ymin = 0;
   Float_t ymax = 1.1*h->GetMaximum();
      
   TCanvas *c1 = new TCanvas("c1");
   c1->SetFillColor(33);
   c1->DrawFrame(ymin,xmin,ymax,xmax);
   
   //loop on bins and draw a TPave
   Float_t width = 0.25;
   Float_t xbinmin = ymin;
   TPave *pave;
   for (Int_t i=1;i<=nbins;i++) {
      Float_t xbinmax = h->GetBinContent(i);
      Float_t ybin = h->GetBinCenter(i);
      Float_t ybinmin = ybin -width*h->GetBinWidth(i);
      Float_t ybinmax = ybin +width*h->GetBinWidth(i);
      pave = new TPave(xbinmin,ybinmin,xbinmax,ybinmax);
      pave->SetFillColor(h->GetFillColor());
      pave->Draw();
   }
}           

Hiroki Sato wrote:
> 
> Hi
> 
> Does someone know how to rotate 1D histograms
> by 90 degrees, so that they grow horizontally?
> 
> Hiroki Sato, Kyoto Univ/RIKEN
> Bldg. 510C, Brookhaven Lab.,
> Upton NY, 11973
> Tel. 631-344-8087



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:28 MET