Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
save_batch.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// This macro demonstrates batch image mode of web canvas
4/// When enabled - several images converted into JSON before all together
5/// provided to headless browser to produce image files. Let significantly
6/// increase performance. Important - disable batch mode for flushing remaining images
7///
8/// \macro_code
9///
10/// \author Sergey Linev
11
12void save_batch()
13{
14 // 37 canvases will be collected together for conversion
16
17 auto c = new TCanvas("canvas", "Canvas with histogram");
18
19 auto h1 = new TH1I("hist", "Histogram with random data", 100, -5., 5);
20 h1->SetDirectory(nullptr);
21 h1->FillRandom("gaus", 10000);
22 h1->Draw();
23
24 for (int n = 0; n < 100; ++n) {
25 h1->FillRandom("gaus", 10000);
26 c->SaveAs(TString::Format("batch_image_%03d.png", n));
27 }
28
29 // Important - disabling batch mode also flush remaining images
31}
#define c(i)
Definition RSha256.hxx:101
The Canvas class.
Definition TCanvas.h:23
1-D histogram with an int per channel (see TH1 documentation)
Definition TH1.h:541
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:8970
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
Definition TH1.cxx:3530
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3068
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
static void BatchImageMode(UInt_t n=100)
Configure batch image mode for web graphics.
const Int_t n
Definition legend1.C:16
TH1F * h1
Definition legend1.C:5