Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.12/07
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
draw_th1.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 is welcome!
8 /// \author Axel Naumann <axel@cern.ch>
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 
18 R__LOAD_LIBRARY(libGpad);
19 
20 #include "ROOT/THist.hxx"
21 #include "ROOT/TCanvas.hxx"
22 
23 void draw_th1() {
24  using namespace ROOT;
25 
26  // Create the histogram.
27  Experimental::TAxisConfig xaxis(10, 0., 10.);
28  auto pHist = std::make_shared<Experimental::TH1D>(xaxis);
29  auto pHist2 = std::make_shared<Experimental::TH1D>(xaxis);
30 
31  // Fill a few points.
32  pHist->Fill(1);
33  pHist->Fill(2);
34  pHist->Fill(2);
35  pHist->Fill(3);
36 
37  pHist2->Fill(5);
38  pHist2->Fill(6);
39  pHist2->Fill(6);
40  pHist2->Fill(7);
41 
42  // Create a canvas to be displayed.
43  auto canvas = Experimental::TCanvas::Create("Canvas Title");
44  canvas->Draw(pHist).SetLineColor(Experimental::TColor::kRed);
45  canvas->Draw(pHist2).SetLineColor(Experimental::TColor::kBlue);
46 
47  canvas->Show();
48 }
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Objects used to configure the different axis types.
Definition: TAxis.hxx:300
static constexpr PredefinedRGB kBlue
Definition: TColor.hxx:187
static constexpr PredefinedRGB kRed
Definition: TColor.hxx:185
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:470
static std::shared_ptr< TCanvas > Create(const std::string &title)
Definition: TCanvas.cxx:63