Macro illustrating how to superimpose two histograms with different scales on the RCanvas.
It shows exactly same data as in hist/twoscales.C macro, but with fully interactive graphics
void th1_twoscales()
{
auto h1 = std::make_shared<TH1F>(
"h1",
"Example histogram",100,-3,3);
for (int i=0;i<10000;i++)
auto hint1 = std::make_shared<TH1F>("hint1","h1 bins integral",100,-3,3);
hint1->SetDirectory(nullptr);
for (int i=1;i<=100;i++) {
hint1->SetBinContent(i,
sum);
}
hint1->SetLineColor(
kRed);
hint1->GetYaxis()->SetAxisColor(
kRed);
hint1->GetYaxis()->SetLabelColor(
kRed);
auto canvas = RCanvas::Create("Two TH1 with two independent Y scales");
canvas->Show();
}
R__EXTERN TRandom * gRandom
Provides v7 drawing facilities for TObject types (TGraph, TH1, TH2, etc).
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
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...
static uint64_t sum(uint64_t i)
- Date
- 2021-07-05
- Warning
- This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
- Author
- Sergey Linev s.lin.nosp@m.ev@g.nosp@m.si.de
Definition in file th1_twoscales.cxx.