Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh3_large.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_rcanvas
3///
4/// This macro generates really large RH2D histogram, fills it with predefined pattern and
5/// draw it in a RCanvas, using Optmize() drawing mode
6///
7/// \macro_image (rcanvas_js)
8/// \macro_code
9///
10/// \date 2020-06-26
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
23#include "ROOT/RCanvas.hxx"
24#include "ROOT/RFrameTitle.hxx"
25#include "ROOT/RHistStatBox.hxx"
26#include "ROOT/RFrame.hxx"
27#include "TString.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_large()
36{
37 const int nbins = 200;
38
39 // Create the histogram.
40 RAxisConfig xaxis("x", nbins, 0., nbins);
41 RAxisConfig yaxis("y", nbins, 0., nbins);
42 RAxisConfig zaxis("z", nbins, 0., nbins);
43 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
44
45 for(int i=0;i<nbins;++i)
46 for(int j=0;j<nbins;++j)
47 for(int k=0;k<nbins;++k)
48 pHist->Fill({1.*i,1.*j,1.*k}, i+j+k);
49
50 // Create a canvas to be displayed.
51 auto canvas = RCanvas::Create("Large 200x200x200 RH3 drawing");
52
53 auto frame = canvas->AddFrame();
54
55 // should we made special style for frame with palette?
56 // frame->margins.right = 0.2_normal;
57
58 frame->x.zoomMin = nbins*0.1;
59 frame->x.zoomMax = nbins*0.9;
60 frame->y.zoomMin = nbins*0.1;
61 frame->y.zoomMax = nbins*0.9;
62 frame->z.zoomMin = nbins*0.1;
63 frame->z.zoomMax = nbins*0.9;
64
65 canvas->Draw<RFrameTitle>(TString::Format("Large RH3D histogram with %d x %d x %d bins",nbins,nbins,nbins).Data());
66
67 auto draw = canvas->Draw(pHist);
68
69 draw->line.color = RColor::kLime;
70 // draw->Box(); // configure box draw option (default)
71 // draw->Sphere(); // configure sphere draw option
72 draw->Scatter(); // configure scatter draw option
73 // draw->Color(); // configure color draw option
74
75 draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
76
77 // auto stat = canvas->Draw<RHist2StatBox>(pHist, "hist");
78 // stat->fill.color = RColor::kBlue;
79 // stat->fill.style = RAttrFill::kSolid;
80
81 canvas->SetSize(1000, 700);
82 canvas->Show();
83}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:472
Objects used to configure the different axis types.
const char * Data() const
Definition TString.h:369
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2336