Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
save_batch.C File Reference

Detailed Description

This macro demonstrates batch image mode of web canvas When enabled - several images converted into JSON before all together provided to headless browser to produce image files.

Let significantly increase performance. Important - disable batch mode for flushing remaining images

void save_batch()
{
// 37 canvases will be collected together for conversion
auto c = new TCanvas("canvas", "Canvas with histogram");
auto h1 = new TH1I("hist", "Histogram with random data", 100, -5., 5);
h1->SetDirectory(nullptr);
h1->FillRandom("gaus", 10000);
h1->Draw();
for(int n = 0; n < 100; ++n) {
h1->FillRandom("gaus", 10000);
c->SaveAs(TString::Format("batch_image_%03d.png", n));
}
// Important - disabling batch mode also flush remaining images
}
#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:540
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:8958
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition TH1.cxx:3519
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
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
Author
Sergey Linev

Definition in file save_batch.C.