Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rh1_large.cxx File Reference

Detailed Description

This macro generates really large RH1D histogram, fills it with predefined pattern and draw it in a RCanvas, using Optmize() drawing mode.

/*************************************************************************
* Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "ROOT/RCanvas.hxx"
#include "ROOT/RFrameTitle.hxx"
#include "ROOT/RFrame.hxx"
#include "TMath.h"
#include "TString.h"
// macro must be here while cling is not capable to load
// library automatically for outlined function see ROOT-10336
R__LOAD_LIBRARY(libROOTHistDraw)
using namespace ROOT::Experimental;
void rh1_large()
{
const int nbins = 5000000;
// Create the histogram.
RAxisConfig xaxis("x", nbins, 0., nbins);
auto pHist = std::make_shared<RH1D>(xaxis);
for(int i=0;i<nbins;++i)
pHist->Fill(1.*i, 1000.*(2+TMath::Sin(100.*i/nbins)));
// Create a canvas to be displayed.
auto canvas = RCanvas::Create("Drawing large RH1");
auto frame = canvas->AddFrame();
frame->gridX = true;
frame->gridY = true;
frame->x.zoomMin = nbins*0.2;
frame->x.zoomMax = nbins*0.8;
canvas->Draw<RFrameTitle>(TString::Format("Large RH1D histogram with %d bins",nbins).Data());
auto draw = canvas->Draw(pHist);
draw->line.color = RColor::kLime;
// draw->fill.color = RColor::kLime;
// draw->fill.style = RAttrFill::kSolid;
// draw->Line(); // configure line draw option
// draw->Bar(); // configure bar draw option
// draw->Error(3); // configure error drawing
draw->Hist(); // configure hist draw option, default
draw->optimize = true; // enable draw optimization, reduced data set will be send to clients
auto stat = canvas->Draw<RHist1StatBox>(pHist, "hist");
stat->fill.color = RColor::kBlue;
stat->fill.style = RAttrFill::kSolid;
canvas->SetSize(1000, 700);
canvas->Show();
}
#define R__LOAD_LIBRARY(LIBRARY)
Definition Rtypes.h:472
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: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
Double_t Sin(Double_t)
Definition TMath.h:589
Date
2020-07-02
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
Author
Sergey Linev s.lin.nosp@m.ev@g.nosp@m.si.de

Definition in file rh1_large.cxx.