Thursday, March 12, 2009

Installing gnuplot on Mac OS X 10.5 (Leopard)

Not to many people's surprise anymore, I'm both an engineer and a Mac user. While this would have been a serious anomaly a couple years ago, it seems more and more common these days, especially when working with other Unix/Linux machines. That aside, I had long been plotting all my data using the various functions in Matlab, and for the most part, I was very happy with the results (see here for reference). What I found, however, is that 3D scatter plots came out looking pretty terrible, and my start in molecular dynamics simulations required the scatter plots somewhat frequently.

So, there I was, looking lustfully at the gnuplot demos, so rich in their 3D visualization options. However, after downloading, extracting, and messing around in the terminal I found latest build (4.2.4) was having some issues with the makefile, even after configuration. I searched on the web for a while for some help which was fruitless until I stumbled upon this little nugget, which was a great relief, as I tend to be sort of lazy when sifting through readme's. To be honest, that entry alone has all the information you really need, but it assumes some basic awareness of a few things I hadn't heard about before, so I thought I'd post this information in a more outright manner.
  1. MacPorts: Probably one of the coolest things ever, simple as hell, and quite powerful. MacPorts allows you to install a number of software packages by simply typing "install packagename" in the Terminal. Installation of MacPorts is a breeze once you download their disk image (.dmg) and run their installer (.mpkg), which you can get here.
  2. Once MacPorts has been installed, you'll need to start a new Terminal session. At that point, it's as easy as typing "sudo port install gnuplot" in the Terminal. I'll warn you, this installation can take a while (~30 minutes) as you download and install all the smaller software packages required.
And that's about it. Just start the terminal up and type "gnuplot". If there are any questions, leave a comment. I've only done this on 10.5, but MacPorts claims to support the latest OS, and the last release (10.4 for now). I have no reason to doubt anything they say considering how simple this all was. They should start some funny rumors since their credibility is so high right now.

UPDATE: Thanks to some feedback, I failed to note that you should install X11 and XCode before attempting to install MacPorts. X11 is available on your OS X install disc, and XCode is available (at no cost) on the Apple Developer webpage.


  1. hello! I am running mac Os 10.5.6 and I foolowed your instructions and got the following error message:
    Error: Target returned: This port requires 'pbxbuild/xcodebuild', which couldn't be found (not MacOS X?)
    How can I fix this?

  2. This comment has been removed by the author.

  3. Alright, upon further review... I would make sure you have both X11 and XCode installed. X11 is the xwindows environment for Mac OS X, and XCode is an integrated development environment freely available through For reference check

  4. Sir. I have done everything according to what you have described above, GNUPLOT has loaded successfully, yet when i give a plotting command (it executes it) but no additional window opens displaying a graph.
    I am fairly new to gnuplotting on a mac.

  5. Gnuplot on Mac OS X requires Aquaterm, did this come along with the Gnuplot install you ran? If not, you can get the Aquaterm package at sourceforge. Once installed, you can type "set term aqua" to use that within gnuplot. Hope this helps, it's actually be a while since I've done any serious plotting.

  6. Hello, I have followed your instructions but it is not working exactly. Gnuplot starts up and and it is automatically set to term aqua.
    I have also installed x11 and xcode.

    when i run a test of 'plot sin(x)', aquaterm boots up and then nothing happens... no graph pops up or anything. a new command line is not given either, giving me the impression that it is "stuck" trying to plot this graph.

  7. i have just tried this:
    set term x11
    plot sin(x)

    and it works... but it still doesn't work for aquaterm, which is what i'd prefer... any reasoning to this?

  8. Wow! Thanks for this easy and step-by-step guide! This page was the fourth hit (somewhat appropriate given the site's moniker) on Google, and by far the most useful! Great post!

  9. I have downloaded both applications but when I type in "sudo port install gnuplot" i receive the error "sudo: port: command not found"

    Any idea what I am doing wrong?

  10. Frankie@ Just read the very first post and along with the "Update" along with. You will have to install Macports, before
    that one should install X11 (from the disc 1) and then XCode (free source).

    If you need further help. Go to this page

    doodah@ Thank you!

  11. @ Banana Grabber

    I do also agree with you. With set term x11, it's working well. I have still but problem with aqua term. Any solution, mod?

  12. I just want to thank you. You helped me a lot with this post!
    Afters two hours of struggling I could easily install gnuplot and even if at the beginning I had the same problem of Banana Grabber now I'm able to get graphs.
    Very useful page, not many are so clear and useful onthe web.
    Keep it on!

  13. I have never use Macports before.
    I am trying to install gnuplot and aquaterm.

    I recently bought a new Mac mini and OS X(snow leopard)and am familiar with some unix( not expert)
    Great job!

  14. This comment has been removed by the author.

  15. I get the following error message: Error: db46 requires the Java for Mac OS X development headers.
    Error: Download the Java Developer Package from:

    I've tried to download teh java developers package eithout any succes. What do i do?

  16. Worked like a champ - thanks.

  17. @Huguito, I got the same problem. Did you ever fix it? someone help!

  18. Thank you very much!! Your blog was by far the best explanation I found (and it has a cool name!!:) ) .

    This goes very smoothly (OS 10.6.3) with MacPorts installed.

    Thanks again!