Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.16/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
23#include "ROOT/RHist.hxx"
24#include "ROOT/RCanvas.hxx"
25#include "ROOT/RColor.hxx"
26#include "ROOT/TDirectory.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.
46
47 // Create a canvas to be displayed.
48 auto canvas = RCanvas::Create("Canvas Title");
49 canvas->Draw(pHist)->SetLineColor(RColor::kRed);
50
51 canvas->Show();
52}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:471
@ kRed
Definition: Rtypes.h:63
Objects used to configure the different axis types.
Definition: RAxis.hxx:300
static TDirectory & Heap()
Dedicated, process-wide TDirectory.
Definition: TFile.cxx:23
void Add(std::string_view name, const std::shared_ptr< T > &ptr)
Add an existing object (rather a shared_ptr to it) to the TDirectory.
Definition: TDirectory.hxx:172