Logo ROOT   6.18/05
Reference Guide
draw_subpads.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// \macro_code
5///
6/// \date 2018-03-13
7/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
8/// \author Sergey Linev
9
10/*************************************************************************
11 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
12 * All rights reserved. *
13 * *
14 * For the licensing terms see $ROOTSYS/LICENSE. *
15 * For the list of contributors see $ROOTSYS/README/CREDITS. *
16 *************************************************************************/
17
19#include "ROOT/RCanvas.hxx"
20#include "ROOT/RPad.hxx"
21
22void draw_subpads() {
23 using namespace ROOT::Experimental;
24
25 // Create the histogram.
26 RAxisConfig xaxis(10, 0., 10.);
27 auto pHist1 = std::make_shared<RH1D>(xaxis);
28 auto pHist2 = std::make_shared<RH1D>(xaxis);
29 auto pHist3 = std::make_shared<RH1D>(xaxis);
30
31 // Fill a few points.
32 pHist1->Fill(1);
33 pHist1->Fill(2);
34 pHist1->Fill(2);
35 pHist1->Fill(3);
36
37 pHist2->Fill(5);
38 pHist2->Fill(6);
39 pHist2->Fill(6);
40 pHist2->Fill(7);
41
42 pHist3->Fill(4);
43 pHist3->Fill(5);
44 pHist3->Fill(5);
45 pHist3->Fill(6);
46
47 // Create a canvas to be displayed.
48 auto canvas = RCanvas::Create("Canvas Title");
49
50 // Divide canvas on sub-pads
51
52 auto subpads = canvas->Divide(2,2);
53
54 subpads[0][0]->Draw(pHist1)->Line().SetColor(RColor::kRed);
55 subpads[1][0]->Draw(pHist2)->Line().SetColor(RColor::kBlue);
56 subpads[0][1]->Draw(pHist3)->Line().SetColor(RColor::kGreen);
57
58 // Divide pad on sub-sub-pads
59 auto subsubpads = subpads[1][1]->Divide(2,2);
60
61 subsubpads[0][0]->Draw(pHist1)->Line().SetColor(RColor::kBlue);
62 subsubpads[1][0]->Draw(pHist2)->Line().SetColor(RColor::kGreen);
63 subsubpads[0][1]->Draw(pHist3)->Line().SetColor(RColor::kRed);
64
65 canvas->Show();
66}
@ kRed
Definition: Rtypes.h:64
@ kGreen
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
Objects used to configure the different axis types.
Definition: RAxis.hxx:300