Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh1_large.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_rcanvas
3///
4/// This macro generates really large RH1D 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-07-02
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 "TMath.h"
28#include "TString.h"
29
30using namespace ROOT::Experimental;
31
32void rh1_large()
33{
34 const int nbins = 5000000;
35
36 // Create the histogram.
37 RAxisConfig xaxis("x", nbins, 0., nbins);
38 auto pHist = std::make_shared<RH1D>(xaxis);
39
40 for(int i=0;i<nbins;++i)
41 pHist->Fill(1.*i, 1000.*(2+TMath::Sin(100.*i/nbins)));
42
43 // Create a canvas to be displayed.
44 auto canvas = RCanvas::Create("Drawing large RH1");
45
46 auto frame = canvas->AddFrame();
47
48 frame->gridX = true;
49 frame->gridY = true;
50 frame->x.zoomMin = nbins*0.2;
51 frame->x.zoomMax = nbins*0.8;
52
53 canvas->Draw<RFrameTitle>(TString::Format("Large RH1D histogram with %d bins",nbins).Data());
54
55 auto draw = canvas->Draw(pHist);
56
57 draw->line.color = RColor::kLime;
58 // draw->fill.color = RColor::kLime;
59 // draw->fill.style = RAttrFill::kSolid;
60 // draw->Line(); // configure line draw option
61 // draw->Bar(); // configure bar draw option
62 // draw->Error(3); // configure error drawing
63 draw->Hist(); // configure hist draw option, default
64
65 draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
66
67 auto stat = canvas->Draw<RHist1StatBox>(pHist, "hist");
68 stat->fill.color = RColor::kBlue;
69 stat->fill.style = RAttrFill::kSolid;
70
71 canvas->SetSize(1000, 700);
72 canvas->Show();
73}
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
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588