// sine_plot.c Doug Toussaint 9/23/09 // very simple exercise for PhilsPlot // plot a sine wave #include #include #include //faraday #include "/home/doug/PhilsPlot/include/philsplot.h" // to compile: // cc -o program_5_1 program_5_1.c /home/doug/PhilsPlot/lib/libphilsplot.a // /home/doug/PhilsPlot/lib/libphilsplot.a \ // -lX11 -lpng /usr/lib/gcc/i386-redhat-linux/3.4.6/libg2c.a -lm -lstdc++ // main(){ double x; // Initialize the plotting // argument is size in pixels open_plot("500x500"); // arguments are xmin, xmax, ymin, ymax, char_size, color, // x_label, y_label, title, right_label box_plot(0.0, 10.0, -1.1, 1.1, 2.0, 1, "X", "sine(x)", "", ""); locate_plot(0.0, 0.0 ); // move to here, for( x=0.0; x< 10.001; x+= 0.1 ){ // plot the point // arguments are x, y, color, linestyle, linewidth drawto_plot( x, sin(x), 1, 1, 1); // For lines // For points, use // putpoint_plot(time, T, 4, 1, 2, 2.0, 1); // if (time>0.0) delpoint_plot(); flush_plot(); delay_plot(100); // 0.1 seconds per segment, just for fun } // Finish up the plotting flush_plot(); delay_plot(5e3); close_plot(); }