Well, I haven't done anything with Gnuplot, but if it accepts command line arguments and outputs graphical data to files or standard output, then it's really quite simple.
You just use PHP's ability to call command-line programs, and you pass the variables to the programs. Then you can take either the file created by Gnuplot or the output stream, and just output it to the browser with the right content/type header at the top.