Mountain Lion, X11, and Gnuplot
Only a year after Lion's release, Mountain Lion has arrived. This post is not a review of the OS X 10.8, nor is it a review of the review. Rather, I'll talk about how its screwed up Gnuplot.
A couple months ago, I wrote a post about installing Octave on Lion. After installing Mountain Lion, Gnuplot just stopped plotting stuff. First, I hunted down AquaTerm (what Gnuplot defaults to plotting in). Launching it independently (located in /Applications/Gnuplot.app/Contents/Resources/lib) and got this lovely message:
Check with the developer to make sure AquaTerm works with this version of OS X.
I knew that Gnuplot could also plot in X11, so I tried launching X11. My system responded with "What X11?" and led me to the Apple support site:
X11 is not included with Mountain Lion, but X11 server and client libraries for OS X Mountain Lion are available from the XQuartz project: http://xquartz.macosforge.org. You should use XQuartz version 2.7.2 or later.
Followed the link, downloaded the package, and installed XQuartz. Now things in Gnuplot work after typing set term 'x11'. To default Gnuplot to X11, add export GNUTERM='x11'. Now when you plot with Octave it should plot with Gnuplot in X11. However, if X11 isn't running, Gnuplot erroneously tries to launch the original X11.app:
The file /Applications/Utilities/X11.app does not exist.
To fix this, symlink X11.app to XQuartz.app. And then you're done!
TL;DR: AquaTerm is not compatible with Mountain Lion and X11 isn't included. Follow steps to get Gnuplot to work.
Download and install XQuartz
Add export GNUTERM='x11' to your environment (e.g. .bash_profile)
ln -sf /Application/Utilities/XQuartz.app/ X11.app
UPDATE #1: Clarified instructions
I have received several emails over the course of the last few months for step-by-step instructions of the process. Here's what I've been sending to people:
1. Download XQuartz(XQuartz-2.7.2.dmg)
XQuartz is X11, which is a window emulator in which GNUplot can run and plot stuff.
2. Download XCode from the AppStore
I'm not sure if this step is necessary because I already had this installed prior to having installed GNUplot. This development package (around 1.5 GB) is a hefty download. To check if you need to do this step, try launching XQuartz after you install it. If you cannot install XQuartz/ cannot launch XQuartz, install XCode first. If it still doesn't work, install commandline tools in XCode. Do this by launching Xcode, in the menu bar XCode > Preferences. Then go to the Downloads tab and install the Command Line Tools.
3. Link XQuartz to X11 in terminal
Open up Terminal (located in /Applications/Utilities/). Or you can use spotlight (cmd+space) and type Terminal to launch it. If you are unfamiliar with UNIX, terminal is a text based operating level in which you can execute commands/run processes.
In the terminal, copy/paste or type:
sudo ln -sf /Applications/Utilities/XQuartz.app/ /Applications/Utilities/X11.app
This will prompt you for a password to execute the changes. What this does is really a patch for Mountain Lion. Previously, X11 was supported in all installations of OSX. However, with Mountain Lion, they removed this support. So we downloaded and installed XQuartz, but older applications still look for XQuartz by the name of X11. By running this command, we make a link from X11 to XQuartz.
4. Add the default terminal emulator as x11
GNUplot (which you will download in the next step) tries to run plots in a terminal emulator called AquaTerm, which is packaged with GNUplot. HOWEVER, AquaTerm does not run on Mountain Lion! So we must set the terminal emulator as X11, which is just XQuartz. To get GNUplot to automatically run in XQuartz, enter this in terminal:
echo "export GNUTERM='x11'" >> .bash_profile
The first command, changes your directory to your "Home" directory. This is the directory where we need to place a script that will allow GNUplot to read some default settings. The second command will insert the necessary changes to your settings in the file ".bash_profile"
5. Download Octave and GNUPlot (octave-3.4.0-i386.dmg)
You do not have to install Octave, but if you choose to, mount octave-3.4.0-i386.dmg by double clicking on it, and then copy (or drag) Octave.app to /Applications/. If you cannot find the /Applications/ folder, try cmd+clicking Safari and it should bring you right there. To install GNUplot, go to theExtras folder and copy gnuplot.app into your /Applications/ folder.
5.1. Repair the Gnuplot-4.4.3 included with Octave-3.4.0 DMG
Open /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot in a text editor. Use the editor search-and-replace feature to replace "DYLD_LIBRARY_PATH" with "DYLD_FALLBACK_LIBRARY_PATH". There are four instances that need to be replaced.
6. Launch gnuplot.app (the one in the /Applications/ folder)
You should be set! Don't forget to unmount the install images you mounted. Usually you can find little eject buttons in the lefthand bar in Finder.
UPDATE #2: I've been told by another reader, Saleem, that Aquaterm does indeed work with ML again as described here.