Monday, April 30, 2018

Installing Octave on OSX with Graphics (For Graphing and Plotting) Enabled

This article is relevant for: 
- Octave version 3.8.0
- OSX (Specifically on 1version 0.11.6)
it may or may not work for other versions.

A Surface Plot generated by Octave

Octave GNU is a free, open source programming language and environment that is very useful if you want to get started with Machine Learning or data visualisation. Installing Octave via Octave Forge on a Mac used to be very complicated but over time it has got a lot easier thanks to an official installer that walks you through the process.

But I did have some issues getting the full functionality up and running and here are the steps I took to resolve the problems. By following the below steps you will have GNC Octave running with full Graphing capabilities.

1) Download the Octave 3.8.0 installer here, its a large file so it will take some time

2) Follow the Installer's instructions and will have the Octave-cli and Octave-gui available on your computer

3) Opening the Octave-cli will open the Terminal with the Octave command prompt active

4) You can now run your Octave scripts and code from here

5) Octave has graphical plotting built into it, for e.g. when you run "plotData(X, y);" it should bring up a window with the X and y data plotted onto a graph. But you may face an issue here in case a Graphics Engine has not been allocated to Octave-cli. The error you see will be something similar to: 

WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
What we have to do is to install QT as the engine and assign it to Octave-cli. 

Here is how you do it:

- Open your standard OSX terminal and type:
- If this command does not work, then you will need to install it with QT like so (use install instead of reinstall if more appropriate)
brew reinstall gnuplot --with-qt
- Now when you re-type "gnuplot" you should see it work and show that the engine is QT (it will say something like - Terminal type os now 'qt')

In gnuplot, now run the command
set terminal
This will list all the available terminals and confirm that QT exists. If you confirmed this then all that is left to do is to configure Octave-cli to use it. If needed you can select QT as the engine from here as well.

- Back in your Octave-cli terminal, type this command

- You will have to restart the terminal (or you may have to restart your computer as well)

6) You should now have Octave-cli working with full graphics capability.

Hope this helps someone.

1 comment:

Fork me on GitHub