Octave freeze when it needs to plot - macos

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.

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.

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.

The first plot after starting Octave 4 can last a while.
Reference: http://wiki.octave.org/Octave_for_MacOS_X

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.

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

Related

Duplicated characters and non-updating input using tmux in zsh

First off:
I'm using tmux 2.5 installed via homebrew on OS X 10.12, in iTerm 2 (though the problem appears in Terminal.app as well). My tmux.conf is on Github, along with my zshrc.
The problem: Seemingly out of nowhere, I started seeing an issue with typing in the prompt. Typing keys once will display them twice, and backspacing will move the cursor forward and redraw characters already present on the line. This only happens inside of a tmux session, and not inside my "regular" terminal.
Here's a gif of the issue. In this gif, I type 1234567890, then hit backspace 9 times, and type ls. Note that 0 only shows up once, and lls with a duplicated l runs the ls command as expected.
Hopefully I just hit a weird key combo on accident, but I've been stuck on this for a while.
Thanks for any help!
Installing tmux-256color for macOS as in this guide solves the problem.
Running the following as mentioned in a github issue solved the problem for me:
brew install ncurses
$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color tmux-256color.info
infocmp tmux-256color | head
I'm also running into this issue as well. I encountered the problem similar to #artemave, by trying to change the set -g default-terminal "screen-256color" to set -g default-terminal "tmux-256color". The goal of doing this was to gain italics, per the tmux FAQ.
#taylor's answer didn't work for me, as I didn't have that command.
I managed to determine that:
The issue doesn't occur with bash
When running a blank .zshrc, backspacing creates new blank lines, but I'm not seeing the character duplication
Using tmux-256color will successfully give italic fonts
Using TERM=xterm-256color and TERM=konsole-256color does not change the above effects
Using xfce4terminal (0.8.9.1), Konsole (19.12.3), or URXVT (9.22) doesn't change the above behavior
I wasn't able to really "fix" the issue, as the even going down to a blank .tmux.conf wasn't able to change anything. Instead, I just needed to change it to anything else. xterm-256color was suggested in this issue, but I found nearly anything else would work fine.
I'll keep working on it and update this answer if I find anything else.
Edit: This tmux issue is the exact issue we're running into. I'll see if the solutions there work
https://github.com/tmux/tmux/issues/597
Edit 2: I've submitted a GitHub issue with tmux. No real results yet, but it does offer some guidance on things to check on.
The problem seems to be fixed after commenting out this line from my tmux.conf:
set -g default-command "reattach-to-user-namespace -l zsh"
I also had to manually run tmux kill-server instead of relying on just re-sourcing my conf file.
When I find some time, I'll look more into what went wrong here...

Octave graphic error with the gnuplot installed(with aqua)

I installed the Octave in OSX 10.11.1 with Homebrew. And while I running the following code:
plot(x,y);
It turns out this:
gnuplot> set terminal aqua enhanced title "Figure 1" font "*,6.66667" dashlength 1
^
line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list
WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
But, actually, I installed the gnuplot with aqua first. And I set the setenv('GNUTERM','aqua') in Octave.
while I enter the gnuplot, after typedset term it shows the list with aqua.
So, I am confused about the problem. how this aqua does not work?

Textmate error running commands after Yosemite upgrade

I recently upgraded my Mac to Yosemite, and now many Textmate 2 commands that I used to use all the time are failing and giving the following error—in this example I tried to run the "Comment line" command by pressing ⌘/:
The same thing happens for "Run", "Toggle String / Symbol", and many other Textmate commands.
When I click "Edit Command", it takes me to a script the first line of which is:
#!/usr/bin/env ruby18
If I take the 18 off of that, it seems to work, but I would have to do it for every command. There must be a better way.
I use rbenv and long ago I set my TM_RUBY variable to $HOME/.rbenv/shims/ruby, but setting or unsetting that doesn't seem to make a difference now. I also tried adding that path to TM's PATH variable. Any other ideas?
I figured out an answer. Running ruby18 at the command line produced a "command not found" error. So I created a symlink to the system ruby (which is ruby 2.0) with that name:
ln -s /usr/bin/ruby /usr/local/bin/ruby18
That seems to have worked. Still not sure if that's the best solution. Open to any other ideas.

Customizing Octave

I am just starting with Octave and running it on my terminal so far.
Everytime I open the prompt, my command line starts with :
octave-3.4.0:1>
So I use the following to make it shorter and easier to read:
PS1('>> ')
How can I change my settings to exectute this code automatically everytime I open octave?
How top of this, is there a way to change my terminal settings to open Octave when I enter 'Octave'? The way I do it now is by using
'exec 'path/to/octave/
Thanks
You can create edit ~/.octaverc file that contains all the commands you want to execute when Octave starts up. This file is exactly like a .m Octave script file.
Just add PS1('>> ') to your ~/.octaverc file. You can use your favorite text editor or use echo on the command line:
$ echo "PS1('>> ')" >> ~/.octaverc
After that you can see the ~/.octaverc file :
$ more ~/.octaverc
It should contain the following line :
PS1('>> ')
For the second question, I am not sure if you're on OSX or Ubuntu or something else. If octave is in your search-path then you should be able to start Octave by just trying octave. Try these commands to find out what octave points to
$ which octave
/usr/bin/octave
$ type octave
octave is /usr/bin/octave
If somehow, octave is not your PATH search-path, this could be because you installed Octave at a non-standard location. You can do one of two things:
Add the folder containing your Octave executable to your PATH search-path. In bash, you can do this by adding the following line to your ~/.bashrc (or ~/.profile on MacOSX):
export PATH=~/path/to/octave/folder:${PATH}
You can create a soft symlink to your octave executable.
ln -s /path/to/octave/executable octave
This will create a symlink in your current folder. Now, as long as you're in the current folder, you'll be able to type in octave and run Octave. If you want to be able to run Octave from anywhere (and not necessarily the current folder), you need to add the current folder to your search-path (see point 1 above).
Consider using the latest release which is GNU Octave 3.8. It comes with a nice GUI if you're familiar with MATLAB.
You can customize the PS1 and any other settings on your ~/.octaverc. Please read the documentation on startup files: http://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
As for calling Octave from anywhere, you need to set the PATH variable in your shell to append the directory where Octave is installed, for instace in Bash:
export PATH=$PATH:/path/to/octave-3.8/bin
Start GNU Octave with option --traditional (but I'm not sure if this was already implemented in 3.4.x).
$ octave --traditional
GNU Octave, version 3.8.1
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.
Octave was configured for "x86_64-unknown-linux-gnu".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html
Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.
>> version
ans = 3.8.1
>>

gnuplot: unrecognized terminal option

Can anyone tell me why I get the "unrecognized terminal option" when having
set output "out.pdf"
Is there any package that I need to install for gnuplot 4.4?
Have you set the terminal? The command
print GPVAL_TERMINALS
in gnuplot will list all the avialable terminals; if pdfcairo is in the list you should be good to go. In general before setting the output you need to set the terminal, e.g.
set terminal pdf
set output 'out.pdf'
Well, I had the same problem. I fixed this as follows using home-brew.
a) First to check what options are available with gnuplot
brew options gnuplot
This will produce something like :
--with-aquaterm
Build with AquaTerm support
--with-cairo
Build the Cairo based terminals
--with-libcerf
Build with libcerf support
--with-pdflib-lite
Build with pdflib-lite support
--with-qt#5.7
Build with qt#5.7 support
--with-test
Verify the build with make check
--with-wxmac
Build wxmac support. Need with-cairo to build wxt terminal
--with-x11
Build with x11 support
--without-gd
Build without gd based terminals
--without-lua
Build without the lua/TikZ terminal
--HEAD
Install HEAD version
b) uninstall gnuplot
brew uninstall gnuplot
c) reinstall with option cairo
brew install gnuplot --with-cairo
That's it. Afterwards, just set the terminal and provide output file. It worked for me.
set term pdf
set output 'myFile.pdf'
Another way is using the pipe gnuplot capability. For example with ps2pdf:
set term postscript eps enhanced color
set output '|ps2pdf - outputfile.pdf'
or with gs directly:
set output '|gs -sDEVICE=pdfwrite -sOutputFile=outputfile.pdf -dBATCH -dNOPAUSE -f -'
where the symbol - means the piped input file

Resources