Skip to content

Commit 67c6222

Browse files
committed
Update tutorial to generate the png image
1 parent 42f5957 commit 67c6222

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

tutorials/v7/draw_th1.cxx

+30-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/// \file
22
/// \ingroup tutorial_v7
33
///
4+
/// This macro generates a small V7 TH1D, fills it and draw it in a V7 canvas.
5+
/// The canvas is display in the web browser and the corresponding png picture
6+
/// is generated.
7+
///
48
/// \macro_code
59
///
610
/// \date 2015-03-22
@@ -15,34 +19,35 @@
1519
* For the list of contributors see $ROOTSYS/README/CREDITS. *
1620
*************************************************************************/
1721

18-
R__LOAD_LIBRARY(libGpad);
22+
R__LOAD_LIBRARY(libROOTGpadv7);
1923

2024
#include "ROOT/THist.hxx"
2125
#include "ROOT/TCanvas.hxx"
2226

2327
void draw_th1() {
24-
using namespace ROOT;
25-
26-
// Create the histogram.
27-
Experimental::TAxisConfig xaxis(10, 0., 10.);
28-
auto pHist = std::make_shared<Experimental::TH1D>(xaxis);
29-
auto pHist2 = std::make_shared<Experimental::TH1D>(xaxis);
30-
31-
// Fill a few points.
32-
pHist->Fill(1);
33-
pHist->Fill(2);
34-
pHist->Fill(2);
35-
pHist->Fill(3);
36-
37-
pHist2->Fill(5);
38-
pHist2->Fill(6);
39-
pHist2->Fill(6);
40-
pHist2->Fill(7);
41-
42-
// Create a canvas to be displayed.
43-
auto canvas = Experimental::TCanvas::Create("Canvas Title");
44-
canvas->Draw(pHist)->SetLineColor(Experimental::TColor::kRed);
45-
canvas->Draw(pHist2)->SetLineColor(Experimental::TColor::kBlue);
46-
47-
canvas->Show();
28+
using namespace ROOT;
29+
30+
// Create the histogram.
31+
Experimental::TAxisConfig xaxis(10, 0., 10.);
32+
auto pHist = std::make_shared<Experimental::TH1D>(xaxis);
33+
auto pHist2 = std::make_shared<Experimental::TH1D>(xaxis);
34+
35+
// Fill a few points.
36+
pHist->Fill(1);
37+
pHist->Fill(2);
38+
pHist->Fill(2);
39+
pHist->Fill(3);
40+
41+
pHist2->Fill(5);
42+
pHist2->Fill(6);
43+
pHist2->Fill(6);
44+
pHist2->Fill(7);
45+
46+
// Create a canvas to be displayed.
47+
auto canvas = Experimental::TCanvas::Create("Canvas Title");
48+
canvas->Draw(pHist)->SetLineColor(Experimental::TColor::kRed);
49+
canvas->Draw(pHist2)->SetLineColor(Experimental::TColor::kBlue);
50+
51+
canvas->Show();
52+
canvas->SaveAs("th1.png");
4853
}

0 commit comments

Comments
 (0)