Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
canvas3.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \preview Example of canvas partitioning with ratios
4/// The TPad::DivideRatios method enables partitioning of the canvas according to different
5///
6/// \macro_image
7/// \macro_code
8///
9/// \author Olivier Couet
10
11void colorpads(TCanvas *C, int n) {
12 TPad *p;
13 for (int i =1; i<=n; i++) {
14 p = (TPad*)C->cd(i);
15 p->SetFillColor(100+i);
16 p->Modified();
17 p->Update();
18 }
19}
20
21void canvas3() {
22 // canvas divided 2x2 with 4 different ratios along X and Y
23 auto C1 = new TCanvas("C1", "C1", 400, 400);
24 C1->DivideRatios(2, 2, {.2,.8}, {.4,.6}); colorpads(C1,4);
25
26 // canvas divided 2x3 with ratios defined only in X
27 auto C2 = new TCanvas("C2", "C2", 400, 0, 400, 400);
28 C2->DivideRatios(2, 3, {.2,.8}); colorpads(C2,6);
29
30 // canvas divided 2x2 with no ratios defined
31 auto C3 = new TCanvas("C3", "C3", 0, 455, 400, 400);
32 C3->DivideRatios(2, 2); colorpads(C3,4);
33
34 // canvas divided 2x2 with ratios and margins
35 auto C4 = new TCanvas("C4", "C4", 400, 455, 400, 400);
36 C4->DivideRatios(2, 2, {.2,.7}, {.4,.5}, 0.05, 0.01); colorpads(C4,4);
37}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
The Canvas class.
Definition TCanvas.h:23
The most important graphics class in the ROOT system.
Definition TPad.h:28
const Int_t n
Definition legend1.C:16
constexpr Double_t C()
Velocity of light in .
Definition TMath.h:115