Logo ROOT   6.19/01
Reference Guide
draw_rh1.cxx File Reference

Detailed Description

This macro generates a small V7 TH1D, fills it and draw it in a V7 canvas.

The canvas is display in the web browser and the corresponding png picture is generated.

/*************************************************************************
* Copyright (C) 1995-2019, 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 "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_rh1()
{
// Create the histogram.
RAxisConfig xaxis(25, 0., 10.);
auto pHist = std::make_shared<RH1D>(xaxis);
auto pHist2 = std::make_shared<RH1D>(xaxis);
for (int n=0;n<1000;n++) {
pHist->Fill(gRandom->Gaus(3,0.8));
pHist2->Fill(gRandom->Gaus(7,1.2));
}
// Create a canvas to be displayed.
auto canvas = RCanvas::Create("Canvas Title");
auto draw1 = canvas->Draw(pHist);
draw1->AttrLine().SetColor(RColor::kRed).SetWidth(2);
auto draw2 = canvas->Draw(pHist2);
draw2->AttrLine().SetColor(RColor::kBlue).SetWidth(4);
canvas->Show();
}
Date
2015-03-22
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch

Definition in file draw_rh1.cxx.