alec.tu
alec.tu

Reputation: 1757

Showing the figure window with octave

I am a very newbie to octave.

I want to show the figure I plot with octave, but no figure window shows up.

Here is what I want to plot, plot.m

x = load('ex2x.dat');
y = load('ex2y.dat');
figure % open a new figure window
plot(x, y, 'o');
ylabel('Height in meters')
xlabel('Age in years')

I run the script with the command line directly

octave plot.m

The dataset can be downloaded from http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=DeepLearning&doc=exercises/ex2/ex2.html

I have installed image package as the site suggested.

My OS is ubuntu 14.04, I am not sure if I miss something.

I appreciate any help.

Thank you!

Upvotes: 1

Views: 2818

Answers (1)

alec.tu
alec.tu

Reputation: 1757

I found the answer which can be found in Octave's FAQ.

http://wiki.octave.org/FAQ

If you are running an Octave script that includes a plotting command,
the script and Octave may terminate immediately. So the plot window
does show up, but immediately closes when Octave finishes execution.
Alternatively, if using fltk, the plot window needs a readline loop to
show up (the time when Octave is sitting around doing nothing waiting for interactive input).
A common solution is to put a pause command at the end of your script.

So I just to add pause in the end of my script and it shows the window.

Upvotes: 3

Related Questions