Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
logN.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_webcanv
3/// \notebook -js
4/// Logarithmic scales support in web canvas.
5///
6/// Shows support of log2, ln, log8 and log25 scales
7/// Any integer base for logarithm can be specified as well
8///
9/// Functionality available only in web-based graphics
10///
11/// \macro_image (tcanvas_js)
12/// \macro_code
13///
14/// \author Sergey Linev
15
16void logN()
17{
18 auto h1 = new TH1I("hist","Random data", 100, -5, 5);
19 h1->FillRandom("gaus", 10000);
20
21 auto c1 = new TCanvas("c1", "Logarithmic scales", 1200, 800);
22
23 if (!gROOT->IsBatch() && !c1->IsWeb())
24 ::Warning("logN.cxx", "macro will not work without enabling web-based canvas");
25
26 c1->Divide(2,2);
27
28 c1->GetPad(1)->SetLogy(2); // configure log2
29 c1->GetPad(1)->Add(h1, ""); // draw with default draw option
30
31 c1->GetPad(2)->SetLogy(3); // configure ln - 3 is special case
32 c1->GetPad(2)->Add(h1, "l"); // draw histogram as line
33
34 c1->GetPad(3)->SetLogy(8); // configure log8
35 c1->GetPad(3)->Add(h1, "c"); // draw histogram as curve
36
37 c1->GetPad(4)->SetLogy(25); // configure log25
38 c1->GetPad(4)->Add(h1, "E"); // draw histogram as errors
39}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
#define gROOT
Definition TROOT.h:406
The Canvas class.
Definition TCanvas.h:23
1-D histogram with an int per channel (see TH1 documentation)
Definition TH1.h:541
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
Definition TH1.cxx:3530
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5