Octave CLI with AquaTerm on Mac OS X

I’m in need of AquaTerm to plot graphics using gnuplot with octave-cli. In other words, I need the following Octave command to produce a nice little graphical plot

octave:1> sombrero


To install aquaterm using homebrew

brew cask install aquaterm

Check lib and headers are properly linked

ls /usr/local/lib/libaquaterm*
ls /usr/local/include/aquaterm/*

If that lists nothing, run

ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm /usr/local/lib/libaquaterm.dylib
ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm /usr/local/lib/libaquaterm.1.1.1.dylib
mkdir /usr/local/include/aquaterm
ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/Headers/* /usr/local/include/aquaterm/.

Install gnuplot with aquaterm

brew install gnuplot --with-aquaterm

Run gnuplot and check whether terminal is set to aqua

$ gnuplot 

	G N U P L O T
	Version 5.0 patchlevel 6    last modified 2017-03-18

	Copyright (C) 1986-1993, 1998, 2004, 2007-2017
	Thomas Williams, Colin Kelley and many others

	gnuplot home:     http://www.gnuplot.info
	faq, bugs, etc:   type "help FAQ"
	immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'aqua'
gnuplot> test

The test command should produce a nice little plot such as


Prior versions of octave-cli e.g. 3.8.0 use gnuplot, so you don’t have to do anything else. Newer versions of Octave e.g. 4.2.1 use a different graphics toolkit  that leverages OpenGL. You can switch to gnuplot as follows

octave:1> graphics_toolkit ("gnuplot")