Getting gnuplot

Download gnuplot, version 3.8i.0 (this is the latest MacOSX compatible version at the time of the writing of this file).

Installing gnuplot

Open the Terminal, and become superuser by typing in su and typing-in your root password when asked to do so. Then cd to the folder where you downloaded gnuplot (for example /Users/goofy/downloads):
cd /Users/goofy/downloads

Unpack the archive:
tar -zxvf gnuplot-3.8i.0.tar.gz

Go into the newly created directory:
cd gnuplot-3.8i.0

Configure gnuplot (don't break the line):
./configure --prefix=/sw --without-gd --mandir='${prefix}/share/man' --with-readline=gnu --enable-mouse --enable-pm3d --with-png --with-pdf --enable-filledboxes --enable-relative-boxwidth --enable-thin-splines
If you don't have libpng installed, remove the command --with-png. If you don't have teTeX installed or any Terminal-based TeX/LaTeX installation, remove the command --with-pdf.

When it's done, compile:
make

When it's done, install gnuplot:
make install

When it's done, resign from superuser:
exit

Now you should have a working installation of gnuplot in /sw/bin/gnuplot.