Re: [GD-DEVEL] Re: plotting data c++
[email protected] (Ethan Merritt)
| Newsgroups | php.gd.devel |
|---|---|
| Organization | University of Washington |
| Message-ID | <[email protected]> |
On Thursday 31 January 2008 07:05, Patolfo wrote:
> Using gnuplot is what i am doing right now, but if a share my program as
> it has to be, the the other person must have gnuplot
True. But [puts on gnuplot developer hat...] we do try to make gnuplot
easily available to all platforms, so I hope that installing it does not
impose a burden on your end-users.
> besides, the program is
> interactive, so, every time you change the input variables, you have to
> replot, that means to have to use two program at a time, i want it to be
> just one :)
That part does not follow. If you communicate to gnuplot through a
pipe, the user need not even be aware of running two separate programs.
Every time you change input variables, your program can send the
'replot' command to gnuplot without any additional user intervention.
A reasonably common example of this is the Octave package.
Users interact directly with Octave, but Octave itself manages the
screen display by sending commands to gnuplot.
regards,
Ethan
> Yeah sound selfish, excuse me for trying to make a fanvy program by the way.
>
> The code is below:
>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <math.h>
> >
> > /* What are we doing here
> > We are adding harmonics or terms: n in this case, of a sine curve,
> > not a continuous sine curve but a sampled one, this sine curve is
> > depicted by x and sin(x) where x can be seen as the abscissa
> > while sin(x) the ordinate in a cartesian coordinated system,
> > the resulting square wave is seen when plotting x vs y
> > */
> > int main()
> > {
> > FILE *destino = fopen( "destino.txt", "w" );
> >
> > int n,h;
> > float x,pi=3.14159265358979,y=0;
> > printf("Number of terms: ");
> > scanf("%d", &n); /* Read the number of terms -harmonics- for
> > the approximation */
> > /* Definition of the curve points, i.e., sampling points that
> > define the curve */
> > for(x = 0;x <= 2*pi;x+=pi/256)
> > {
> > y=0;
> > // Harmonic number, 1 is the fundamental, 2,4,6... the harmonics
> > for(h = 1;h <= n;h+=2)
> > {
> > // Summation of a sine curve harmonics, point by point
> > y+=sin(h*x)/h;
> > };
> > // Yields the points that define and square wave
> > printf("%-2.8g \n", y);
> > fprintf( destino, "%-2.8g %-2.8g \n", x,y);
> > }
> > fclose(destino);
> > return 0;
> > }
> It gives a file "destino.txt" with a variable number of data pairs
> dpening on the number of samples used, and it is always between 0 and 1.
>
> This is the routine for the dtaa generation, for the gui i am working on
> it, just making fancy with menus and the like, the problem of the plot
> or graph it self is where i am stalled.
>
> Thanks a bunch for your attention
>
--
Ethan A Merritt