16
votes

I have a problem ploting from Octave. Octave and Gnuplot are installed with Homebrew on OS X El Capitan, and after trying to do first plot, I got error:

set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6" dashlength 1

This problem is fixed using instructions from this answer, in short:

brew uninstall gnuplot

sudo ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm /usr/local/lib/libaquaterm.dylib
sudo ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/AquaTerm /usr/local/lib/libaquaterm.1.0.0.dylib
sudo ln -s /Library/Frameworks/AquaTerm.framework/Versions/A/Headers /usr/local/include/aquaterm

brew install gnuplot --with-aquaterm

echo '

Now, when I do plot, eg. plot(rand(3)), then Octave just freeze, so I have to do Control-C to abort. When I try to plot directly from Gnuplot and set term aqua, it works and I get plots. But in Octave, when I want to set term aqua or set term, it reports:

error: invalid conversion from string to real N-d array error: set:

expecting graphics handle as first argument

Also, I tried with:

echo -E "setenv('GNUTERM','X11')" > ~/.octaverc

but that did not help either. I think the problem is with graphics_toolkit, but I do not know how to resolve this.

octave:1> graphics_toolkit aqua

error: graphics_toolkit: aqua toolkit is not available

error: called from graphics_toolkit at line 81 column 5

octave:2> graphics_toolkit fltk

error: graphics_toolkit: fltk toolkit is not available

error: called from graphics_toolkit at line 81 column 5

Update

Accepted solution works up until version 4.2.0-rc2, so now check the update in the answer for more information.

5
Can you check if AppNap gets activated for Octave and/or gnuplot? Open ActivityMonitor and add the AppNap column - Andy
On @Andy, it does not. It remains 'no' for octave. Same goes for gnuplot. - miller
@miller Can you state which octave version you were using ($ octave --version or version()) ? It would be helpful for others since there are some version-specific issues - Jeffrey Mvutu Mabilama

5 Answers

14
votes

I noticed when I enter command available_graphics_toolkits it only shows

ans =

{

[1,1] = gnuplot

}

and wheh I try with loaded_graphics_toolkits, it prints

ans = {}(1x0)

I guesed problem was with not loading GUI environment, so Octave was then recompiled with --with-gui option

brew reinstall octave --with-gui

and that solved a problem.

Update

According to this commit, from last September, version 4.2.0-rc2, --with-gui does not work anymore. So the best it to follow the instruction from Konstantin.

8
votes

The accepted answer from miller didn't work for me, although available_graphics_toolkits and loaded_graphics_toolkits returned similar results. The octave package doesn't seem to have a --with-gui flag anymore.

Instead what I had to do to get it working was first brew reinstall gnuplot --with-x11 and then create a ~/.octaverc with the content

setenv("GNUTERM", "X11")
graphics_toolkit("gnuplot")

I did have X11 preinstalled.

4
votes

The first plot after starting Octave 4 can last a while.

Reference: http://wiki.octave.org/Octave_for_MacOS_X

1
votes

I had to update octave from 4.4.0 to the latest version 5.2.0 to get out of this. But I still can't figure out why the previous version misbehaved in the first place.

0
votes

setenv("GNUTERM","qt") from octave command line solved the problem for me! See Cheng answer: https://stackoverflow.com/a/24596336/7190647