Mail Archives: djgpp/1996/09/16/10:20:27
Douglas Eleveld wrote:
> >Is there a data plotting library for simple 2d plots that one can use from
> >within the djgpp code? I am aware of gnuplot, in fact I'm using it now, but
> >I wanted something callable from within my C programs that could give me a
> >quick look at my data. Any pointers/suggestions/advice welcome.
We've written a library for plotting data as a student's-project which runs fine
and is easy to use. It's written in C++ using GRX2.0 for doing the graphics.
The sources are about 120k, the docs with examples (texinfo) about 85k. The library
supports plots with more than one graph in a chart, automatic and manual scaling,
more than one x- and/or y-axis, linear and logarithmic scaling, ...
As this may look a little bit too complicated, take a look at the example below,
which is Example1 included in the docs.
If anybody is interested in this library, send me personal EMAIL including which
format (BINHEX or UU-Encoded) you want the ZIP. If someone is interested in more
details, I could also send the .inf-file (98k uncompressed, ?? zipped).
Hope this helps,
Roland
+---------------------------------------+---------------------------+
I Roland Exler I EMAIL: I
I Universitaet Linz I R DOT Exler AT jk DOT uni-linz DOT ac DOT at I
I Institut fuer Elektrische Messtechnik I I
I Altenbergerstr. 69 I Phone: I
I A-4040 Linz, AUSTRIA I + 43 732 2468 9205 I
+---------------------------------------+---------------------------+
#include "../plot/plot.h"
#include <grx.h>
#include <mousex.h>
#include <math.h>
// just as example
const int maxSize = 1001; // Length of measurementseries
const float timeStep = 13./maxSize; // scanperiode
float time = 0; // timer
// Simulates the reading or calculation of measurements
float readValue() {
float value;
value=sin(time/2+timeStep)*sin(time*(10+2*sin(2*time)));
time+=timeStep;
return value;
};
int main() {
float yDat[maxSize]; // data-array reserved memory
GrSetMode(GR_default_graphics);
DvLinScale timeScale(timeStep);
DvIndexVec xVec; // generate index-vector
DvScaleData<float> xTimeVec(timeScale,xVec);// generate time-vector
DvScaleData<float> yVec(yDat,maxSize); // generate data-vector
DvXAxis xAxis("Index"); // generate x-axis
DvXAxis xTimeAxis("t / s"); // generate x-time-axis
DvYAxis yAxis(0.2,10.1,"I / A");// generate y-axis
DvNoPoint noPoint; // generate point
DvGraph graph(xVec,xAxis,yVec,yAxis,noPoint,"Graph");
DvPlot plot("Simple Plot-Demo",0,2,2);
plot.add(graph); // insert graph in plot
plot.add(xTimeAxis); // insert time-axis
for(int i=0;i<maxSize;i++) { // reading measurements
yDat[i]=readValue();
//wait timer
};
xTimeAxis.gridOn(); // enable grid
yAxis.gridOn();
// set userdefined bounds to time-axis
xTimeAxis.setNewScale(xTimeVec[0],xTimeVec[yVec.getSize()-1]);
plot.show(); // show plot on screen
getkey();
GrSetMode(GR_default_text);
return 0;
};
- Raw text -