Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
draw_rh3_large.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
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_code
8///
9/// \date 2020-06-26
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
22#include "ROOT/RCanvas.hxx"
23#include "ROOT/RFrameTitle.hxx"
24#include "ROOT/RHistStatBox.hxx"
25#include "ROOT/RFrame.hxx"
26#include "TString.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_large()
35{
36 const int nbins = 200;
37
38 // Create the histogram.
39 RAxisConfig xaxis("x", nbins, 0., nbins);
40 RAxisConfig yaxis("y", nbins, 0., nbins);
41 RAxisConfig zaxis("z", nbins, 0., nbins);
42 auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
43
44 for(int i=0;i<nbins;++i)
45 for(int j=0;j<nbins;++j)
46 for(int k=0;k<nbins;++k)
47 pHist->Fill({1.*i,1.*j,1.*k}, i+j+k);
48
49 // Create a canvas to be displayed.
50 auto canvas = RCanvas::Create("Canvas Title");
51
52 auto frame = canvas->GetOrCreateFrame();
53
54 // should we made special style for frame with palette?
55 // frame->Margins().SetRight(0.2_normal);
56
57 frame->AttrX().SetZoom(nbins*0.1, nbins*0.9);
58 frame->AttrY().SetZoom(nbins*0.1, nbins*0.9);
59 frame->AttrZ().SetZoom(nbins*0.1, 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->AttrLine().SetColor(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->AttrFill().SetColor(RColor::kBlue);
75
76 canvas->SetSize(1000, 700);
77 canvas->Show();
78}
#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:2331