问题
I'm using Windows 7 64 bit. Each time, I'm using plot function, plot windows will shows and draws successfully, but after that it stops responding and must shut down it.
For example :
x = linspace(0,1,10)
y = x.^2
plot(x,y);
Strangely, when plot windows freeze and I must close octave windows, they will be unresponsive too. This will not happen if I don't use plot function.
I don't know why. Does it because I'm using 64 bit version? Please tell me how to fix this.
回答1:
The problem is likely to be the graphics toolkit which your installation of Octave is using.
To check this, type graphics_toolkit
in the Octave command line.
If the response is fltk
and your plot window is freezing, then switch the default toolkit to gnuplot: graphics_toolkit('gnuplot')
Test that the problem is fixed: x=1:10; y=x.^2; plot(x,y)
Make the change permanent in your octave.rc file, located in your Octave installation directory:
On Windows: \Octave\share\octave\site\m\startup\octaverc
On Linux: ~/.octaverc
Still not working?
If response is
qt
, try eitherfltk
orgnuplot
(one may be faster than the other).If the above does not work, you may need to install/re-install gnuplot. (thanks to lukas and saurabh for this edge case).
回答2:
As Assad Ebrahim wrote, the problem is with the toolkit. I got another problem in version 3.8.2. that the gnuplot didn't work at all. No plot windows showed and a I needed to close Octave. If someone have the same problem, the solution is to download gnuplot and install it to Octave folder. It replaces old gnuplot and the new one is working.
And I thank you for the advice.
回答3:
Oh. My friend shows me this command and it works fine :
pkg rebuild -noauto oct2mat
The command reinstalls the package but marks it to not load by default at startup. This behavior has now been changed and new releases of Forge packages will NOT load by default.
The problem is that the package oct2mat should never be loaded. It shadows several functions of Octave core so it starts acting weird. Unless you really have a need for this package you better off just removing it.
The purpose of oct2mat is to make up for the lack of missing functions in Matlab and make code written for Octave run in Matlab. If you don't need oct2mat, remove it. No one needs all packages installed, and it can actually make your Octave install worse such as in the case of oct2mat.
回答4:
So on windows, this worked for me:
Step 1:
Install gnuplot to C:\Program Files (x86)\gnuplot
:
Download link:
https://sourceforge.net/projects/gnuplot/
Step 2: Goto below given directory(considering you have installed Octave in C:\ root):
C:\Octave\share\octave\site\m\startup
open octaverc
file present in that directory in Notepad.
Step 3:
Add following lines to the end of the file.
gnuplot_binary 'C:\Program Files (x86)\gnuplot\bin\gnuplot.exe'
graphics_toolkit('gnuplot')
Step 4:
Save the file and exit the Notepad. If Octave
is open please close it too.
Step 5:
Open Octave
and type following command in it to check:
plot([1,2,3],[4,5,6]);
Please note for the first time it might take
gnuplot
upto 5 minutes to render the graph. So, please do not try to close the app. Subsequent simple plots renders pretty quickly, usually under 1 second.
回答5:
Answer given by Assad is absolutely right and worked well for me too.
This is just an Exception Case.
After you type in the Octave command line : graphics_toolkit
If the answer is qt
instead of fltk
, then probably your PC needs to be installed gnuplot separately from SourceForge as Octave gets some errors while installing itself in W8/10.
Here is the link attached. https://sourceforge.net/projects/gnuplot/?source=directory
You don't need to change any installation files.
This should work
回答6:
When I first tested plotting an example graph, the graph window appeared but did not respond for one to two minutes, then the plot appeared. Further plots appeared instantly. O.S.: Windows 7 64 bit Octave 4.0.3 64 bit.
回答7:
I have similar symptoms using octave 4.2 when running your code (Cannot close plot windows, plot takes time to appear). When statements don't end with semicolon (;) the command and result will be printed in command window. It SEEMS to me that the command window halts interpretation of code and wait for user to press a valid key (f,b,q) to contunure or abort execution. The halt point is dependent on previously executed code and size of command window, therefore the intermittent nature of these symptoms.
Solution:
Option 1: Go to command window and keep pressing f (forward)
Option 2: Use semicolon to terminate statements
x = linspace(0,1,10);
y = x.^2;
plot(x,y);
Option 3: Fiddle with some command window settings
Hope it helps
回答8:
I had the same problem in version 4.0.3 and switching the default toolkit to gnuplot as Assad Ebrahim said did not work for me. Then I find something in Octave for Microsoft Windows:
Current octave for windows ships a not full featured gnuplot. Therefore you cannot use the full features of gnuplot graphics toolkit
And there is instruction of how to download and install gnuplot. Hope it is helpful to you.
回答9:
The following is solution for plot window freezing when running Octave from within Emacs, credited to John Lawrence Aspden and user2699 from the question How to get Octave's plot to work under emacs?. It's brought here because this question is much easier to find.
The problem might be caused by Emacs octave-mode's --no-line-editing
switch, you can fix it by M-x customize-variable RET inferior-octave-startup-args RET
and change --no-line-editing
to --line-editing
.
来源:https://stackoverflow.com/questions/12032494/plot-window-not-responding