Gnuplot is a really good idea. In case you want another, a really nice option in the pngwriter libraries. It can be installed from synaptic (libpng12-0) and (libpng12-dev).
You can find full details on the package at
which details how to do everything you could want.
For an simple example program take the following.
Once you installed pngwriter, compile the above, remembering to link to the pngwriter library (check the link above if stuck how to do this) and bob's your uncle.
/*Make a 400,300 white window called test*/
for(i = 1; i < 900;i++)
png.plot(i,150+100*sin((double)i*45/900.0), 1.0, 0.0, 0.0);
/*The above plots a red sin graph*/
system("eog test.png");/*If you want to show the file*/
system("rm test.png");/*If you want the remove the file after*/