Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh3.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_rcanvas
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_image (rcanvas_js)
8/// \macro_code
9///
10/// \date 2020-06-18
11/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
12/// \author Sergey Linev <s.linev@gsi.de>
13
14/*************************************************************************
15 * Copyright (C) 1995-2020, 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#include "ROOT/RHist.hxx"
24#include "ROOT/RCanvas.hxx"
25#include "ROOT/RPad.hxx"
26#include "ROOT/RFrameTitle.hxx"
27#include "TRandom.h"
28
29// macro must be here while cling is not capable to load
30// library automatically for outlined function see ROOT-10336
31R__LOAD_LIBRARY(libROOTHistDraw)
32
33using namespace ROOT::Experimental;
34
35void rh3()
36{
37 // Create the histogram.
38 RAxisConfig xaxis("x", 10, -5., 5.);
39 RAxisConfig yaxis("y", 10, -5., 5.);
40 RAxisConfig zaxis("z", 10, -5., 5.);
41 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
42
43 for (int n=0;n<10000;n++)
44 pHist->Fill({gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.)});
45
46 // Create a canvas to be displayed.
47 auto canvas = RCanvas::Create("RH3D drawing options");
48
49 // Divide canvas on 2x2 sub-pads to show different draw options
50 auto subpads = canvas->Divide(2,2);
51
52 // default draw option
53 subpads[0][0]->Draw<RFrameTitle>("Box(0) default draw option");
54 subpads[0][0]->Draw(pHist)->Box(0).fill = RAttrFill(RColor::kBlue, RAttrFill::kSolid);
55
56 // sphere draw options
57 subpads[1][0]->Draw<RFrameTitle>("Sphere(1) draw option");
58 subpads[1][0]->Draw(pHist)->Sphere(1);
59
60 // text draw options
61 subpads[0][1]->Draw<RFrameTitle>("Color() draw option");
62 subpads[0][1]->Draw(pHist)->Color();
63
64 // arrow draw options
65 subpads[1][1]->Draw<RFrameTitle>("Scatter() draw option");
66 subpads[1][1]->Draw(pHist)->Scatter().fill = RAttrFill(RColor::kBlack, RAttrFill::kSolid);
67
68 canvas->SetSize(1000, 700);
69 canvas->Show();
70}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:491
Drawing fill attributes for different objects.
Definition RAttrFill.hxx:26
Objects used to configure the different axis types.
const Int_t n
Definition legend1.C:16