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

Detailed Description

This macro generates RH2D and draw it with different options in RCanvas.

/*************************************************************************
* Copyright (C) 1995-2021, 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/RHist.hxx"
#include "ROOT/RFrameTitle.hxx"
#include "ROOT/RCanvas.hxx"
#include "ROOT/RPad.hxx"
#include "TRandom.h"
using namespace ROOT::Experimental;
void rh2()
{
// Create the histogram.
RAxisConfig xaxis("x", 20, 0., 10.);
RAxisConfig yaxis("y", 20, 0., 10.);
auto pHist = std::make_shared<RH2D>(xaxis, yaxis);
for (int n=0;n<10000;n++)
pHist->Fill({gRandom->Gaus(5.,2.), gRandom->Gaus(5.,2.)});
// Create a canvas to be displayed.
auto canvas = RCanvas::Create("RH2 drawing options");
// Divide canvas on 2x3 sub-pads to show different draw options
auto subpads = canvas->Divide(2,3);
// default draw option
subpads[0][0]->Draw<RFrameTitle>("Color() draw option (default)");
subpads[0][0]->Draw(pHist);
// contour draw options
subpads[1][0]->Draw<RFrameTitle>("Contour() draw option");
subpads[1][0]->Draw(pHist)->Contour();
// text draw options
subpads[0][1]->Draw<RFrameTitle>("Text() draw option");
subpads[0][1]->Draw(pHist)->Text().text.color = RColor::kBlue;
// arrow draw options
subpads[1][1]->Draw<RFrameTitle>("Arrow() draw option");
auto draw11 = subpads[1][1]->Draw(pHist);
draw11->Arrow();
draw11->line.color = RColor::kRed;
// lego draw options
subpads[0][2]->Draw<RFrameTitle>("Lego() draw option");
subpads[0][2]->Draw(pHist)->Lego(2);
// surf draw option
subpads[1][2]->Draw<RFrameTitle>("Surf() draw option");
subpads[1][2]->Draw(pHist)->Surf(2);
canvas->SetSize(1000, 700);
canvas->Show();
}
Objects used to configure the different axis types.
const Int_t n
Definition legend1.C:16
Date
2020-06-25
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 rh2.cxx.