Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
draw_rh3.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// This macro generates a small RH3D, fills it with random values and
5/// draw it in RCanvas, using configured web browser
6///
7/// \macro_code
8///
9/// \date 2020-06-18
10/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
11/// \author Sergey Linev <s.linev@gsi.de>
12
13/*************************************************************************
14 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
15 * All rights reserved. *
16 * *
17 * For the licensing terms see $ROOTSYS/LICENSE. *
18 * For the list of contributors see $ROOTSYS/README/CREDITS. *
19 *************************************************************************/
20
21#include "ROOT/RHist.hxx"
23#include "ROOT/RCanvas.hxx"
24#include "ROOT/RPad.hxx"
25#include "ROOT/RFrameTitle.hxx"
26#include "TRandom.h"
27
28// macro must be here while cling is not capable to load
29// library automatically for outlined function see ROOT-10336
30R__LOAD_LIBRARY(libROOTHistDraw)
31
32using namespace ROOT::Experimental;
33
34void draw_rh3()
35{
36 // Create the histogram.
37 RAxisConfig xaxis("x", 10, -5., 5.);
38 RAxisConfig yaxis("y", 10, -5., 5.);
39 RAxisConfig zaxis("z", 10, -5., 5.);
40 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
41
42 for (int n=0;n<10000;n++)
43 pHist->Fill({gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.)});
44
45 // Create a canvas to be displayed.
46 auto canvas = RCanvas::Create("RH3D drawing options");
47
48 // Divide canvas on 2x2 sub-pads to show different draw options
49 auto subpads = canvas->Divide(2,2);
50
51 // default draw option
52 subpads[0][0]->Draw<RFrameTitle>("Box(0) default draw option");
53 subpads[0][0]->Draw(pHist)->Box(0).AttrFill().SetColor(RColor::kBlue);
54
55 // sphere draw options
56 subpads[1][0]->Draw<RFrameTitle>("Sphere(1) draw option");
57 subpads[1][0]->Draw(pHist)->Sphere(1);
58
59 // text draw options
60 subpads[0][1]->Draw<RFrameTitle>("Color() draw option");
61 subpads[0][1]->Draw(pHist)->Color();
62
63 // arrow draw options
64 subpads[1][1]->Draw<RFrameTitle>("Scatter() draw option");
65 subpads[1][1]->Draw(pHist)->Scatter().AttrFill().SetColor(RColor::kBlack);
66
67 canvas->SetSize(1000, 700);
68 canvas->Show();
69}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:472
Objects used to configure the different axis types.
const Int_t n
Definition legend1.C:16