Re: [ROOT] Labeling a THStack?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Mar 23 2004 - 09:48:01 MET


Hi Ed,

See example below

Rene Brun

void hstack() {
   
   THStack *hs = new THStack("hs","test stacked histograms");
   //create three 1-d histograms
   TH1F *h1 = new TH1F("h1","test hstack",100,-4,4);
   h1->FillRandom("gaus",20000);
   h1->SetFillColor(kRed);
   h1->SetMarkerStyle(21);
   h1->SetMarkerColor(kRed);
   hs->Add(h1);
   TH1F *h2 = new TH1F("h2","test hstack",100,-4,4);
   h2->FillRandom("gaus",15000);
   h2->SetFillColor(kBlue);
   h2->SetMarkerStyle(21);
   h2->SetMarkerColor(kBlue);
   hs->Add(h2);
   TH1F *h3 = new TH1F("h3","test hstack",100,-4,4);
   h3->FillRandom("gaus",10000);
   h3->SetFillColor(kGreen);
   h3->SetMarkerStyle(21);
   h3->SetMarkerColor(kGreen);
   hs->Add(h3);
   
   TCanvas *c1 = new TCanvas("c1","stacked hists",10,10,1000,800);
   c1->SetFillColor(41);
   hs->Draw();
   hs->GetXaxis()->SetTitle("the X axis");
   hs->GetYaxis()->SetTitle("the Y axis");
   c1->Modified();
}

On Mon, 
22 
Mar 2004, Edward Chen wrote:

> Hi - I'm having problems labeling a THStack on the x-axis.  With a TH1F, I
> can call SetXTitle(), but I don't see anything like this available for the
> THStack.  I also did try SetXTitle() on the individual histos that went
> into the stack, but to no avail.  What's the best way to do this then?
> Thanks.
> 
> -Ed
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET