Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave freeze when it needs to plot

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.

like image 252
miller Avatar asked Jan 21 '16 14:01

miller


3 Answers

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.

like image 183
miller Avatar answered Oct 20 '22 20:10

miller


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.

like image 8
KonstantinK Avatar answered Oct 20 '22 19:10

KonstantinK


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

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

like image 4
Huang C. Avatar answered Oct 20 '22 20:10

Huang C.