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
29using namespace ROOT::Experimental;
30
31void rh3_large()
32{
33 const int nbins = 200;
34
35 // Create the histogram.
36 RAxisConfig xaxis("x", nbins, 0., nbins);
37 RAxisConfig yaxis("y", nbins, 0., nbins);
38 RAxisConfig zaxis("z", nbins, 0., nbins);
39 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
40
41 for(int i=0;i<nbins;++i)
42 for(int j=0;j<nbins;++j)
43 for(int k=0;k<nbins;++k)
44 pHist->Fill({1.*i,1.*j,1.*k}, i+j+k);
45
46 // Create a canvas to be displayed.
47 auto canvas = RCanvas::Create("Large 200x200x200 RH3 drawing");
48
49 auto frame = canvas->AddFrame();
50
51 // should we made special style for frame with palette?
52 // frame->margins.right = 0.2_normal;
53
54 frame->x.zoomMin = nbins*0.1;
55 frame->x.zoomMax = nbins*0.9;
56 frame->y.zoomMin = nbins*0.1;
57 frame->y.zoomMax = nbins*0.9;
58 frame->z.zoomMin = nbins*0.1;
59 frame->z.zoomMax = nbins*0.9;
60
61 canvas->Draw<RFrameTitle>(TString::Format("Large RH3D histogram with %d x %d x %d bins",nbins,nbins,nbins).Data());
62
63 auto draw = canvas->Draw(pHist);
64
65 draw->line.color = RColor::kLime;
66 // draw->Box(); // configure box draw option (default)
67 // draw->Sphere(); // configure sphere draw option
68 draw->Scatter(); // configure scatter draw option
69 // draw->Color(); // configure color draw option
70
71 draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
72
73 // auto stat = canvas->Draw<RHist2StatBox>(pHist, "hist");
74 // stat->fill.color = RColor::kBlue;
75 // stat->fill.style = RAttrFill::kSolid;
76
77 canvas->SetSize(1000, 700);
78 canvas->Show();
79}
Objects used to configure the different axis types.
const char * Data() const
Definition TString.h:376
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:2378