Logo ROOT   6.18/05
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-2015, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
// R__LOAD_LIBRARY(libROOTGpadv7);
#include "ROOT/RCanvas.hxx"
void draw_rh1() {
using namespace ROOT::Experimental;
// Create the histogram.
RAxisConfig xaxis(10, 0., 10.);
auto pHist = std::make_shared<RH1D>(xaxis);
auto pHist2 = std::make_shared<RH1D>(xaxis);
// Fill a few points.
pHist->Fill(1);
pHist->Fill(2);
pHist->Fill(2);
pHist->Fill(3);
pHist2->Fill(5);
pHist2->Fill(6);
pHist2->Fill(6);
pHist2->Fill(7);
// Create a canvas to be displayed.
auto canvas = RCanvas::Create("Canvas Title");
auto draw1 = canvas->Draw(pHist);
draw1->Line().SetColor(RColor::kRed).SetWidth(2);
auto draw2 = canvas->Draw(pHist2);
draw2->Line().SetColor(RColor::kBlue).SetWidth(4);
canvas->Show();
}
@ kRed
Definition: Rtypes.h:64
@ kBlue
Definition: Rtypes.h:64
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.