Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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-2019, 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 "ROOT/RCanvas.hxx"
20#include "ROOT/RColor.hxx"
22
23// macro must be here while cling is not capable to load
24// library automatically for outlined function see ROOT-10336
25R__LOAD_LIBRARY(libROOTHistDraw)
26
27void draw()
28{
29 using namespace ROOT::Experimental;
30
31 // Create the histogram.
32 RAxisConfig xaxis("x", 10, 0., 1.);
33 RAxisConfig yaxis("y", {0., 1., 2., 3., 10.});
34 auto pHist = std::make_shared<RH2D>(xaxis, yaxis);
35
36 // Fill a few points.
37 pHist->Fill({0.01, 1.02});
38 pHist->Fill({0.54, 3.02});
39 pHist->Fill({0.98, 1.02});
40 pHist->Fill({1.90, 1.02});
41 pHist->Fill({0.75, -0.02});
42
43 // Create a canvas to be displayed.
44 auto canvas = RCanvas::Create("Canvas Title");
45 auto draw1 = canvas->Draw(pHist);
46 // draw1->AttrLine().SetColor(RColor::kRed);
47
48 auto other = std::make_shared<RH2D>(*pHist);
49 auto draw2 = canvas->Draw(other);
50 // draw2->AttrLine().SetColor(RColor::kBlue).SetWidth(12);
51
52 canvas->Show();
53}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:472
Objects used to configure the different axis types.