Setting up Octave and Gnuplot on Apple Mac OSX

I just started auditing a Mathematical Models in Biology class and Matlab is one of the requirements. I had relatively good experience with the free, open source alternative,Octave back in college, but then I was running Linux, not OSX. It took me about an hour to figure out how to set it up (I was a little worried for a bit).

  1. Download the Octave binary for OSX from Octaveforge.
  2. Install Octave and Gnuplot (in the extras folder). I just dragged them to /Applications (X11 is required for Gnuplot—should be found on OSX install disk)
  3. Set the environment variable for gnuplot (Octave is supposed to do this automatically, but it didn’t for me):sudo ln -s /Applications/GnuPlot.app/Contents/Resources/bin/gnuplot /usr/bin/gnuplot
    (thanks for the help, Toby)
  4. Download and install (again in /Applications) Aquaterm which will actually render the gnuplot graphs.
  5. Within Gnuplot, set the renderer: “terminal aqua”
  6. Try it out in Octave (I had to restart Octave and Gnuplot to get it all to work):x = linspace(-pi, pi, 100);
    y = sin(x);
    plot(x, y);

Thank you: High Performance Computing for Mac OS X, the Octave Wiki and Google for helping me find what I needed.


14 Responses to “Setting up Octave and Gnuplot on Apple Mac OSX”

Rick on September 27th, 2008

I’m having the same problem as joaquin…. Please Help!!

Thank you!

Daniel Stegmueller on February 5th, 2008

Well, that was really helpful.
I was searching for a gnuplot binary and hadn’t realized that octave provided one…

Thanks a lot!

Best,
Daniel

Toby on February 21st, 2008

Hi, thanks that’s a good explanation. I tried it but it only works when I log in as administrator. Typically I use a standard user account, and then I always get the error message “unable to open display ‘:0.0′ X11 aborted”. On the other hand, if I start X11 first, then plotting works, however, plots are shown directly in X11, not with AquaTerm. Do you have an idea what might be wrong and how it could be fixed?

Toby on February 21st, 2008

Re: AquaTerm problem
Actually, gnuplot works fine with AquaTerm, the problem must be that octave doesn’t talk to gnuplot. For setting up the symbolic link I had to switch user accounts. It would only work from the admin account, and only with ‘sudo’. Did you not have to do that?

Toby on February 21st, 2008

PS: Octave
Hi again, just wanted to let everybody know, that it must be a problem with my current user account. I finally remembered the typical test, i.e., create a clean new user account and see if that works. And it does. In other words, one does not have to be administrator. However, as mentioned above, to create the symbolic link mentioned in the post, the following command has to be entered from an admin account: “sudo ln -s /Applications/GnuPlot.app/Contents/Resources/bin/gnuplot /usr/bin/gnuplot”.

Thanks,
Toby

ben on March 2nd, 2008

Awesome, thanks for the feedback. I’ll update the script—you were right.

tukhmky on March 21st, 2008

pcoK3J uzydqbaqkclx, [url=http://bxswxzilupxf.com/]bxswxzilupxf[/url], [link=http://lxviewksjtxa.com/]lxviewksjtxa[/link], http://gydjbmfaxjcz.com/

joaquin on May 21st, 2008

hi, I installed octave and gnuplot, and when I tried to plot sin(x), octave shows me the following error:

octave-3.0.1:2> plot(x,sin(x))
dyld: Library not loaded: /usr/X11R6/lib/libXpm.4.dylib
Referenced from: /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot-4.2.3
Reason: image not found
dyld: Library not loaded: /usr/X11R6/lib/libXpm.4.dylib
Referenced from: /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot-4.2.3
Reason: image not found
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 75: 3092 Trace/BPT trap GNUTERM=”${GNUTERM}” GNUPLOT_HOME=”${GNUPLOT_HOME}” PATH=”${PATH}” DYLD_LIBRARY_PATH=”${DYLD_LIBRARY_PATH}” HOME=”${HOME}” GNUHELP=”${GNUHELP}” DYLD_FRAMEWORK_PATH=”${DYLD_FRAMEWORK_PATH}” GNUPLOT_PS_DIR=”${GNUPLOT_PS_DIR}” DISPLAY=”${DISPLAY}” GNUPLOT_DRIVER_DIR=”${GNUPLOT_DRIVER_DIR}” “${ROOT}/bin/gnuplot-4.2.3″ “$@”
/Applications/Gnuplot.app/Contents/Resources/bin/gnuplot: line 75: 3098 Trace/BPT trap GNUTERM=”${GNUTERM}” GNUPLOT_HOME=”${GNUPLOT_HOME}” PATH=”${PATH}” DYLD_LIBRARY_PATH=”${DYLD_LIBRARY_PATH}” HOME=”${HOME}” GNUHELP=”${GNUHELP}” DYLD_FRAMEWORK_PATH=”${DYLD_FRAMEWORK_PATH}” GNUPLOT_PS_DIR=”${GNUPLOT_PS_DIR}” DISPLAY=”${DISPLAY}” GNUPLOT_DRIVER_DIR=”${GNUPLOT_DRIVER_DIR}” “${ROOT}/bin/gnuplot-4.2.3″ “$@”
error: you must have gnuplot installed to display graphics; if you have gnuplot installed in a non-standard location, see the ‘gnuplot_binary’ function

and I really don`t know what to do

joaquin on May 21st, 2008

If, someone could help me, I would be very gratefull!

thanks

Juan on December 2nd, 2008

Joaquin,

You are getting this error because you dont have installed (somehow) the X11 environment.
I was having the same problem than you and now it is working without any problem.
You can install it from the Tiger or Leopard DVD or you can surf the web looking for it.

Best,

Juan

regula on February 18th, 2009

Thank You!!
This just safed my day (if not the whole semester or even more :) – beautiful!
Aquaterm was missing (why won’t anyone tell one this) and now all is well.

Maxwell Grady on July 16th, 2009

Thank you so much for this; this totally saved me a lot of time.

Once I found a download link for the correct version of X11 to install on my macbook I just followed your instructions plain and simple and it worked perfect.

Thanks a million.

Optimality! » Setting up Octave and Gnuplot on OSX on February 18th, 2010

[...] Good instructions are here. [...]

Mareo Raft on March 6th, 2010

thank you thank you thank you!!!!

Leave a Reply

(required)

(required)