ShiftEleven

Installing Octave on OSX with MacPorts

Most of the time, installing things with MacPorts is pretty easy; however, I have found that GNU Octave can be a little tricky. That being said, it's still pretty easy to get Octave up and running in both Snow Leopard and Lion.

At the time of this post, here's two version of Octave to choose from: octave (version 3.2.4) and octave-devel (version 3.4.3). For my money, I like octave-devel. In my brief testing with the two, the biggest difference for me was that the graphs plotted in octave-devel looked more like their OS counterparts. With octave, I found the scaling of elements on the graph to be different sizes and that bugged me.

To install Octave, run the following from the terminal:

sudo port install octave-devel +gcc45

And then wait…as there are a lot of things that need being compiled.

I added the gcc45 variant because one of the dependencies, atlas, needs gcc45 to compile. This ensures that both of those are in sync.

Feel free to add other variants if you like, like X11 support or offline documentation. To get a full list, run:

port variants octave-devel

Plotting

When you install Octave via MacPorts, AquaTerm also gets installed. AquaTerm is basically a vector renderer which Octave can use to plot its graphs. I like AquaTerm because the graphs look really smooth and nice, like you would expect on a Mac :)

If you have installed the X11 variant, you can also choose to do the rendering from within X11. The way you control this is through the environment variable, GNUTERM.

Set GNUTERM to x11 when you want to do your graphing in X11 and set GNUTERM to aqua when you want to do your graphing in AquaTerm. You can read more about setting environment variables on StackOverflow.

If you are running Octave and wish to change the GNUTERM there, you can do so with the setenv function, like so.

>> % Create some sample data
>> x = [-4 -2 0 2 4 6 8];
>> y = x .^ 2;
>>
>> % Plot X in X11.
>> setenv("GNUTERM", "x11");
>> plot(x, y);
>>
>> % Plot X in AquaTerm.
>> setenv("GNUTERM", "aqua");
>> plot(x, y);

With this, you can also compare the different rendering apps and discover which one you like more.

Comments

comments powered by Disqus