1 | #include <iostream> |
---|
2 | #include "RpHistogram.h" |
---|
3 | |
---|
4 | int main() |
---|
5 | { |
---|
6 | // histogram object |
---|
7 | Rappture::Histogram *h1 = NULL; |
---|
8 | Rappture::Histogram *h2 = NULL; |
---|
9 | Rappture::Histogram *h3 = NULL; |
---|
10 | |
---|
11 | // data arrays |
---|
12 | double bins[] = {1,2,3,4,5,6,7,8,9,10}; |
---|
13 | double y[] = {1,4,9,16,25,36,49,64,81,100}; |
---|
14 | // double z[] = {1,8,27,64,125,216,343,512,729,1000}; |
---|
15 | size_t binWidths[] = {1,1,1,2,1,1,1,1,1,1}; |
---|
16 | |
---|
17 | // number of points in x, y, z arrays |
---|
18 | size_t nPts = 10; |
---|
19 | size_t nBins = 10; |
---|
20 | |
---|
21 | h1 = new Rappture::Histogram(); |
---|
22 | h1->xaxis("xlabel1","xdesc1","xunits1",bins,nBins); |
---|
23 | h1->yaxis("ylabel1","ydesc1","yunits1",y,nPts); |
---|
24 | h1->binWidths(binWidths,nBins); |
---|
25 | h1->marker(Rappture::Histogram::x,5,"This is five","-foreground red -linewidth 2"); |
---|
26 | |
---|
27 | h2 = new Rappture::Histogram(y,nPts,bins,nBins); |
---|
28 | h2->xaxis("xlabel2","xdesc2","xunits2"); |
---|
29 | h2->yaxis("ylabel2","ydesc2","yunits2"); |
---|
30 | h1->marker(Rappture::Histogram::y,2,"This is two","-foreground blue -linewidth 1"); |
---|
31 | |
---|
32 | double rangeMin = 1.0; |
---|
33 | double rangeMax = 10.0; |
---|
34 | h3 = new Rappture::Histogram(y,nPts,rangeMin,rangeMax,nBins); |
---|
35 | h3->xaxis("xlabel3","xdesc3","xunits3"); |
---|
36 | h3->yaxis("ylabel3","ydesc3","yunits3"); |
---|
37 | |
---|
38 | size_t indent = 0; |
---|
39 | size_t tabstop = 4; |
---|
40 | |
---|
41 | std::printf("xml: %s\n",h1->xml(indent,tabstop)); |
---|
42 | std::printf("xml: %s\n",h2->xml(indent,tabstop)); |
---|
43 | std::printf("xml: %s\n",h3->xml(indent,tabstop)); |
---|
44 | |
---|
45 | return 0; |
---|
46 | } |
---|