Logo ROOT   6.18/05
Reference Guide
draw.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// \macro_code
5///
6/// \date 2015-03-22
7/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
8/// is welcome!
9/// \author Axel Naumann <axel@cern.ch>
10
11/*************************************************************************
12 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
13 * All rights reserved. *
14 * *
15 * For the licensing terms see $ROOTSYS/LICENSE. *
16 * For the list of contributors see $ROOTSYS/README/CREDITS. *
17 *************************************************************************/
18
19#include "Rtypes.h"
20
21R__LOAD_LIBRARY(libROOTHistDraw);
22
24#include "ROOT/RCanvas.hxx"
25#include "ROOT/RColor.hxx"
26#include "ROOT/RDirectory.hxx"
27
28void draw()
29{
30 using namespace ROOT::Experimental;
31
32 // Create the histogram.
33 RAxisConfig xaxis("x", 10, 0., 1.);
34 RAxisConfig yaxis("y", {0., 1., 2., 3., 10.});
35 auto pHist = std::make_shared<RH2D>(xaxis, yaxis);
36
37 // Fill a few points.
38 pHist->Fill({0.01, 1.02});
39 pHist->Fill({0.54, 3.02});
40 pHist->Fill({0.98, 1.02});
41 pHist->Fill({1.90, 1.02});
42 pHist->Fill({0.75, -0.02});
43
44 // Register the histogram with ROOT: now it lives even after draw() ends.
45 RDirectory::Heap().Add("hist", pHist);
46
47 // Create a canvas to be displayed.
48 auto canvas = RCanvas::Create("Canvas Title");
49 auto pOpts = canvas->Draw(pHist);
50 pOpts->BoxLine().SetColor(RColor::kRed);
51
52 RH2D other = *pHist;
53 auto pOptsOther = canvas->Draw(other, *pOpts);
54 pOptsOther->BoxLine().SetColor(RColor::kBlue).SetWidth(12);
55
56 canvas->Show();
57}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:473
@ kRed
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
Objects used to configure the different axis types.
Definition: RAxis.hxx:300
Histogram class for histograms with DIMENSIONS dimensions, where each bin count is stored by a value ...
Definition: RHist.hxx:52