libpgplotxx.a (C++ interface to PGPLOT)

◆ main()

main ( )

example program

Just a simple example to show how the pgplot classes may be used.

See also
pgplot::device

Definition at line 54 of file pgplotxxdemo.cc.

References pgplot::pgaff::array_value_range(), pgplot::basic_device::env(), pgplot::pgaff::gray(), pgplot::basic_device::gwedg(), pgplot::pgaff::line(), pgplot::pgaff::pt(), pgplot::basic_device::pt1(), pgplot::basic_device::subp(), and pgplot::Trange::swap().

55 {
56  cout << "pgplotxxdemo" << endl;
57  cout << "(example program for the C++ interface for PGPLOT)" << endl;
58 
59  /*
60  pgplot::device d("/xserve");
61  d.env(1.,5.,1.,10.,0,2);
62  */
63  pgplot::device d2("/xserve");
64  d2.subp(2,1);
65  /*
66  d2.env(1.,5.,1.,10.,1,2);
67  pgplot::basic_device::ldev();
68  */
69 
70  //----------------------------------------------------------------------
71  // go for gray plot
72 
73  pgplot::pgaff::Tarray A(aff::Shaper(0,6)(-3,3));
74  for (int i=A.first(0); i<=A.last(0); ++i)
75  {
76  for (int j=A.first(1); j<=A.last(1); ++j)
77  {
78  A(i,j)=float(5*i+j);
79  }
80  }
81 
82  pgplot::pgaff::Tarray B1=aff::subarray(A)(4,6)(1,2);
83  pgplot::pgaff::Tarray B2=aff::subarray(A)(0,4)(1,3);
84 
85  pgplot::Trect cwin(pgplot::Trange(-1.,3.),pgplot::Trange(-5.,5.));
86 
87  /*
88  d2.ask();
89  d2.env(cwin);
90  pgplot::pgaff::Ttransform tr=pgplot::pgaff::create_transform(A,cwin);
91  pgplot::Trange vrange=pgplot::pgaff::array_value_range(A).swap();
92  pgplot::pgaff::gray(d2, A, vrange, tr).gwedg(vrange);
93  */
94  d2.env(cwin);
96  pgplot::pgaff::gray(d2, B1, vrange).gwedg(vrange);
97  d2.env(cwin);
98  pgplot::pgaff::gray(d2, B1, false).gwedg(vrange.swap());
99  d2.env(cwin);
100  pgplot::pgaff::gray(d2, B2);
101  d2.env(cwin);
102  pgplot::pgaff::gray(d2, A);
103  /*
104  d2.env(cwin);
105  tr=pgplot::pgaff::create_transform(B2,cwin);
106  vrange=pgplot::pgaff::array_value_range(B2).swap();
107  pgplot::pgaff::gray(d2, B2, vrange, tr).gwedg(vrange);
108  */
109 
110  //----------------------------------------------------------------------
111 
112  const int imax=100;
113  pgplot::pgaff::Tseries x(0,imax-1);
114  pgplot::pgaff::Tseries y(0,imax-1);
115  for (int i=0; i<imax; ++i)
116  {
117  x(i)=std::sin(2.*3.14159265*i/imax);
118  y(i)=std::cos(2.*3.14159265*i/imax);
119  }
120  d2.subp(1,1).env(-1.,1.,-1.,1.,1,2);
121  pgplot::pgaff::line(d2,x,y);
122  pgplot::pgaff::pt(d2,0.6*x,0.6*y,-3);
123  for (int i=0; i<imax; ++i)
124  {
125  d2.pt1(x(i),y(i),i);
126  d2.pt1(0.8*x(i),0.8*y(i),-i);
127  }
128 
129 }
Trange & swap()
swap range
Definition: structs.h:118
Trange array_value_range(const Tarray::Tcoc &a)
return range of values
Definition: affpgplot.cc:164
hold any parameter range
Definition: structs.h:42
pgplot::basic_device & gray(pgplot::basic_device &dev, const Tarray &a, const pgplot::Trange &range, const Ttransform &tr)
function to plot gray image
Definition: affpgplot.cc:52
basic_device & gwedg(const Trange &range, const char *label="value", const float &disp=0.3, const float &width=3.0, const char *side="RG")
annotate an image plot with a wedge
Definition: basicdevice.h:537
aff::Series< float > Tseries
Definition: affpgplot.h:67
aff::Array< float > Tarray
array type to be passed to gray function
Definition: affpgplot.h:66
basic_device & env(const float &xmin, const float &xmax, const float &ymin, const float &ymax, const int &just=0, const int &axis=0)
define PGPLOT window and axis
Definition: basicdevice.h:153
hold any rectangle
Definition: structs.h:130
the standard device class
Definition: device.h:44
T & line(T &dev, const SX &x, const SY &y)
draw an open polygon from a dense series
Definition: affpgplot.h:112
T & pt(T &dev, const SX &x, const SY &y, const int &s)
draw symbols from series
Definition: affpgplot.h:198
Here is the call graph for this function: