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
29using namespace ROOT::Experimental;
30
31void rh3()
32{
33 // Create the histogram.
34 RAxisConfig xaxis("x", 10, -5., 5.);
35 RAxisConfig yaxis("y", 10, -5., 5.);
36 RAxisConfig zaxis("z", 10, -5., 5.);
37 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
38
39 for (int n=0;n<10000;n++)
40 pHist->Fill({gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.)});
41
42 // Create a canvas to be displayed.
43 auto canvas = RCanvas::Create("RH3D drawing options");
44
45 // Divide canvas on 2x2 sub-pads to show different draw options
46 auto subpads = canvas->Divide(2,2);
47
48 // default draw option
49 subpads[0][0]->Draw<RFrameTitle>("Box(0) default draw option");
50 subpads[0][0]->Draw(pHist)->Box(0).fill = RAttrFill(RColor::kBlue, RAttrFill::kSolid);
51
52 // sphere draw options
53 subpads[1][0]->Draw<RFrameTitle>("Sphere(1) draw option");
54 subpads[1][0]->Draw(pHist)->Sphere(1);
55
56 // text draw options
57 subpads[0][1]->Draw<RFrameTitle>("Color() draw option");
58 subpads[0][1]->Draw(pHist)->Color();
59
60 // arrow draw options
61 subpads[1][1]->Draw<RFrameTitle>("Scatter() draw option");
62 subpads[1][1]->Draw(pHist)->Scatter().fill = RAttrFill(RColor::kBlack, RAttrFill::kSolid);
63
64 canvas->SetSize(1000, 700);
65 canvas->Show();
66}
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