Logo ROOT  
Reference Guide
draw_rh3.cxx File Reference

Detailed Description

This macro generates a small RH3D, fills it with random values and draw it in RCanvas, using configured web browser.

/*************************************************************************
* 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/RHist.hxx"
#include "ROOT/RCanvas.hxx"
#include "ROOT/RPad.hxx"
#include "ROOT/RFrameTitle.hxx"
#include "TRandom.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 draw_rh3()
{
// Create the histogram.
RAxisConfig xaxis("x", 10, -5., 5.);
RAxisConfig yaxis("y", 10, -5., 5.);
RAxisConfig zaxis("z", 10, -5., 5.);
auto pHist = std::make_shared<RH3D>(xaxis, yaxis, zaxis);
for (int n=0;n<10000;n++)
pHist->Fill({gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.), gRandom->Gaus(0.,2.)});
// Create a canvas to be displayed.
auto canvas = RCanvas::Create("RH3D drawing options");
// Divide canvas on 2x2 sub-pads to show different draw options
auto subpads = canvas->Divide(2,2);
// default draw option
subpads[0][0]->Draw<RFrameTitle>("Box(0) default draw option");
subpads[0][0]->Draw(pHist)->Box(0).AttrFill().SetColor(RColor::kBlue);
// sphere draw options
subpads[1][0]->Draw<RFrameTitle>("Sphere(1) draw option");
subpads[1][0]->Draw(pHist)->Sphere(1);
// text draw options
subpads[0][1]->Draw<RFrameTitle>("Color() draw option");
subpads[0][1]->Draw(pHist)->Color();
// arrow draw options
subpads[1][1]->Draw<RFrameTitle>("Scatter() draw option");
subpads[1][1]->Draw(pHist)->Scatter().AttrFill().SetColor(RColor::kBlack);
canvas->SetSize(1000, 700);
canvas->Show();
}
Date
2020-06-18
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 draw_rh3.cxx.

n
const Int_t n
Definition: legend1.C:16
RHist.hxx
ROOT::Experimental::RAxisConfig
Objects used to configure the different axis types.
Definition: RAxisConfig.hxx:35
RHistDrawable.hxx
ROOT::Experimental::RColor::kBlack
static constexpr R__DLLEXPORT RGB_t kBlack
Definition: RColor.hxx:178
TRandom.h
ROOT::Experimental::RCanvas::Create
static std::shared_ptr< RCanvas > Create(const std::string &title)
Create new canvas instance.
Definition: RCanvas.cxx:103
RCanvas.hxx
ROOT::Experimental::RColor::kBlue
static constexpr R__DLLEXPORT RGB_t kBlue
Definition: RColor.hxx:186
RPad.hxx
TCanvas::Show
void Show()
Show canvas.
Definition: TCanvas.cxx:2238
ROOT::Experimental
Definition: RDirectory.hxx:30
TPad::Divide
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
Definition: TPad.cxx:1178
R__LOAD_LIBRARY
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:472