source: trunk/examples/objects/plot/plot4.cc @ 1581

Last change on this file since 1581 was 1386, checked in by dkearney, 16 years ago

adding a few object prototypes we can play with for future developement. the plot object is probably the most interesting. examples are located in examples/objects dirs

File size: 1.6 KB
RevLine 
[1386]1#include <iostream>
2#include "RpPlot.h"
3
4int main()
5{
6    // plot object
7    Rappture::Plot *p1 = NULL;
8
9    // data arrays
10    double x[] = {1,2,3,4,5,6,7,8,9,10};
11    double z[] = {1,2,3,4,5,6,7,8,9,10};
12    double y[] = {1,4,9,16,25,36,49,64,81,100};
13
14    // number of points in x, y, z arrays
15    size_t nPts = 10;
16
17    // line format: green line, dotted line style, circle marker
18    const char *fmt = "g:o"
19
20    p1 = new Rappture::Plot();
21
22    // line id handle, not really sure what to do with these yet
23    size_t cid1 = 0;
24    size_t cid2 = 0;
25
26    // add line to the plot, with optional format and line name
27    // line name can be used to retrieve cid later?
28    cid1 = p1->add(nPts,x,y,fmt,"lineName");
29    cid2 = p1->add(nPts,x,z,"b-*");
30    p1->add(nPts,x,x);
31
32    // might want to associate info with a specific cid?
33    // info method implementable with varargs
34    // use 1 call to add multiple properties
35    /*
36    p1->info("xlabel","Voltage",
37              "xdesc","Voltage along the Gate",
38             "xunits","Volt",
39             "xscale","linear");
40    */
41
42    // or use multiple calls to add one property at a time
43    p1->property("ylabel","Current");
44    p1->property("ydesc","Current along the Drain");
45    p1->property("yunits","Amp");
46    p1->property("yscale","log");
47
48    // number of curves in this plot
49    size_t curveCnt = p1->count();
50
51    // const array of line id's
52    // const size_t *lineIds = p1->lines();
53
54    // retrieve cid from curve name
55    // may want to add cid to another plot?
56    cid = p1->line("lineName");
57
58    delete p1;
59
60    return 0;
61}
Note: See TracBrowser for help on using the repository browser.