Generate a line plot with GNUplot
Let's start with a line plot :
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5 set pointintervalbox 2 plot 'plot.dat' with linespoints ls 1 Assuming you put this kind of data in plot.dat (use pwd in GNUplot to see where to put this file). # plotting_data1.dat # X Y 1 1 2 4 3 2 4 1 5 10 6 15 You will get : |
GNUplot line cos plot
Let's start another test with cosinus.
We keep style and line (between points). set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 pi -1 ps 1.5 set pointintervalbox 0 plot cos(x) with linespoints ls 1 This simply print cos values with default sample rate. Who tells GNUplot is hard to use? Let's see the result : |
C code creates a graph automatically using GNUplot
To have a window which opens when you launch the C programs you need to install gnuplot-x11 (or some other gnuplot ui).
Thanks to Maberib for this post. #include This will print your plot into gnuplot user interface. See what we get : |