Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
ZoomHistogram.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Changing the Range on the X-Axis of a Histogram

Image produced by .x ZoomHistogram.C

This demonstrates how to zoom into a histogram by changing the range on one of the axes (or both).

{
TH1F *orig = new TH1F("Normal Histogram", "Normal Histogram", 100, 0, 100);
for (int i = 0; i < 100; ++i) {
Double_t x = gRandom->Gaus(50, 10);
orig->Fill(x);
}
TH1F *zoom = (TH1F *)orig->Clone("zoom");
zoom->SetTitle("Zoomed-in Histogram");
zoom->GetXaxis()->SetRangeUser(50, 100);
TCanvas *c1 = new TCanvas("c1", "Histogram", 1500, 700);
c1->Divide(2, 1);
c1->cd(1);
orig->Draw();
c1->cd(2);
zoom->Draw();
}
double Double_t
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:622
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition TRandom.cxx:275
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
Author
Advait Dhingra

Definition in file ZoomHistogram.C.