Logo ROOT   6.18/05
Reference Guide
draw_rh1.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// This macro generates a small V7 TH1D, fills it and draw it in a V7 canvas.
5/// The canvas is display in the web browser and the corresponding png picture
6/// is generated.
7///
8/// \macro_code
9///
10/// \date 2015-03-22
11/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
12/// \author Axel Naumann <axel@cern.ch>
13
14/*************************************************************************
15 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
16 * All rights reserved. *
17 * *
18 * For the licensing terms see $ROOTSYS/LICENSE. *
19 * For the list of contributors see $ROOTSYS/README/CREDITS. *
20 *************************************************************************/
21
22// R__LOAD_LIBRARY(libROOTGpadv7);
23
25#include "ROOT/RCanvas.hxx"
26
27void draw_rh1() {
28 using namespace ROOT::Experimental;
29
30 // Create the histogram.
31 RAxisConfig xaxis(10, 0., 10.);
32 auto pHist = std::make_shared<RH1D>(xaxis);
33 auto pHist2 = std::make_shared<RH1D>(xaxis);
34
35 // Fill a few points.
36 pHist->Fill(1);
37 pHist->Fill(2);
38 pHist->Fill(2);
39 pHist->Fill(3);
40
41 pHist2->Fill(5);
42 pHist2->Fill(6);
43 pHist2->Fill(6);
44 pHist2->Fill(7);
45
46 // Create a canvas to be displayed.
47 auto canvas = RCanvas::Create("Canvas Title");
48 auto draw1 = canvas->Draw(pHist);
49 draw1->Line().SetColor(RColor::kRed).SetWidth(2);
50
51 auto draw2 = canvas->Draw(pHist2);
52 draw2->Line().SetColor(RColor::kBlue).SetWidth(4);
53
54 canvas->Show();
55}
@ kRed
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
Objects used to configure the different axis types.
Definition: RAxis.hxx:300