ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/setTitleAxes.C
Revision: 1.1
Committed: Sat Sep 6 19:06:19 2008 UTC (16 years, 7 months ago) by anderson
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
Set Titles

File Contents

# User Rev Content
1 anderson 1.1 /* Created by Jeff Klukas
2    
3     Example of usage in root:
4     .X setTitleAxes(hist1, "p_{T} of Reconstructed Muons", "p_{T}")
5     This would change the x-axis title of hist1 to pt and the y axis to
6     "Number of Events per Bin", while the main title would be "pt of
7     Reconstructed muons".
8    
9     This method is implemented for 1-D and 2-D histograms.
10     */
11    
12    
13    
14     void setTitleAxes(TH1 &*hist, TString title, TString XaxisName,
15     TString YaxisName = "Number of Events per Bin",
16     double YaxisOffset = 1.2) {
17     hist->SetTitle(title);
18     hist->GetXaxis()->SetTitle(XaxisName);
19     hist->GetYaxis()->SetTitle(YaxisName);
20     hist->GetYaxis()->SetTitleOffset(YaxisOffset);
21     }
22    
23     void setTitleAxes(TH2 &*hist, TString title, TString XaxisName,
24     TString YaxisName = "Number of Events per Bin",
25     double XaxisOffset = 1.2, double YaxisOffset = 1.2) {
26     hist->SetTitle(title);
27     hist->GetXaxis()->SetTitle(XaxisName);
28     hist->GetYaxis()->SetTitle(YaxisName);
29     hist->GetXaxis()->SetTitle(XaxisName);
30     hist->GetYaxis()->SetTitle(YaxisName);
31     hist->GetXaxis()->SetTitleOffset(XaxisOffset);
32     hist->GetYaxis()->SetTitleOffset(YaxisOffset);
33     }