/* * Examples of gnuplot_i.c usage */ #include #include #include "gnuplot_i.h" #define SLEEP_LGTH 1 void slow_print(char * s); int main ( int argc, char *argv[] ) { gnuplot_ctrl * h1; double phase; slow_print ( "*** example of gnuplot control through C ***\n" ); /* Open a GNUPLOT process. */ h1 = gnuplot_init(); if ( h1 == NULL ) { printf ( "\n" ); printf ( "Please make gnuplot available in your path.\n" ); return 1; } for ( phase = 0.1; phase < 10.0 ; phase = phase + 0.1 ) { gnuplot_resetplot ( h1 ); gnuplot_cmd ( h1, "plot sin(x+%g)", phase ); } for ( phase = 10.0; phase >= 0.1 ; phase = phase - 0.1 ) { gnuplot_resetplot ( h1 ); gnuplot_cmd ( h1, "plot sin(x+%g)", phase ); } /* Close the GNUPLOT process. */ gnuplot_close ( h1 ); return 0; } void slow_print(char * s) { int i; for (i=0; i<(int)strlen(s) ; i++) { printf("%c", s[i]); fflush(stdout); usleep(10000); } }