Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh2_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 rh2_large()
32{
33 const int nbins = 2000;
34
35 // Create the histogram.
36 RAxisConfig xaxis("x", nbins, 0., nbins);
37 RAxisConfig yaxis("y", nbins, 0., nbins);
38 auto pHist = std::make_shared<RH2D>(xaxis, yaxis);
39
40 for(int i=0;i<nbins;++i)
41 for(int j=0;j<nbins;++j)
42 pHist->Fill({1.*i,1.*j}, i+j);
43
44 // Create a canvas to be displayed.
45 auto canvas = RCanvas::Create("Large 2000x2000 RH2 drawing");
46
47 auto frame = canvas->AddFrame();
48
49 // should we made special style for frame with palette?
50 // frame->margins.right = 0.2_normal;
51
52 frame->gridX = false;
53 frame->gridY = false;
54 frame->x.zoomMin = nbins*0.2;
55 frame->x.zoomMax = nbins*0.8;
56 frame->y.zoomMin = nbins*0.2;
57 frame->y.zoomMax = nbins*0.8;
58
59 canvas->Draw<RFrameTitle>(TString::Format("Large RH2D histogram with %d x %d bins",nbins,nbins).Data());
60
61 auto draw = canvas->Draw(pHist);
62
63 draw->line.color = RColor::kLime;
64 // draw->Contour(); // configure cont draw option
65 // draw->Scatter(); // configure scatter draw option
66 // draw->Arrow(); // configure arrow draw option
67 draw->Color(); // configure color draw option (default)
68 // draw->Text(true); // configure text drawing (can be enabled with most 2d options)
69 // draw->Box(1); // configure box1 draw option
70 // draw->Surf(2); // configure surf4 draw option, 3d
71 // draw->Lego(2); // configure lego2 draw option, 3d
72 // draw->Error(); // configure error drawing, 3d
73
74 draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
75
76 auto stat = canvas->Draw<RHist2StatBox>(pHist, "hist");
77 stat->fill.color = RColor::kBlue;
78 stat->fill.style = RAttrFill::kSolid;
79
80 canvas->SetSize(1000, 700);
81 canvas->Show();
82}
RAttrValue< RColor > color
! fill color
Definition RAttrFill.hxx:43
Objects used to configure the different axis types.
RAttrFill fill
! fill attributes
Definition RPave.hxx:48
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