|
1 | 1 | /// \file
|
2 | 2 | /// \ingroup tutorial_v7
|
3 | 3 | ///
|
| 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 | +/// |
4 | 8 | /// \macro_code
|
5 | 9 | ///
|
6 | 10 | /// \date 2015-03-22
|
|
15 | 19 | * For the list of contributors see $ROOTSYS/README/CREDITS. *
|
16 | 20 | *************************************************************************/
|
17 | 21 |
|
18 |
| -R__LOAD_LIBRARY(libGpad); |
| 22 | +R__LOAD_LIBRARY(libROOTGpadv7); |
19 | 23 |
|
20 | 24 | #include "ROOT/THist.hxx"
|
21 | 25 | #include "ROOT/TCanvas.hxx"
|
22 | 26 |
|
23 | 27 | 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"); |
48 | 53 | }
|
0 commit comments