Annotating Plots in Octave
Posted by Hans Fugal
In MATLAB, you can do this:
x = 2*pi*[0:100]/100;
figure(1); plot(sin(x));
figure(2); plot(cos(x));
% ...
figure(1); title('sin(x)');
figure(2); title('cos(x)');
In Octave on OS X, I was having trouble. There were two problems. First, the version of Octave I had (2.1.73) had a bug where it would not just add the title "sin(x)", but replot the current plot (the cosine) and give it the title "sin(x)". Not what I wanted. I upgraded to 2.9.9 and it now works properly provided you solve the other problem.
The other problem is more a misdocumentation. The docs for figure.m read:
Set the current plot window to plot window N. This function currently requires X11 and a version of gnuplot that supports multiple frames. If N is not specified, the next available window number is chosen.
figure is the user-defined function from the file
/usr/local/share/octave/2.9.9/m/plot/figure.m
But if you look at the source it's obvious that it works with AquaTerm as well,
but only if the environment GNUTERM is set to aqua. So put this in your
~/.bashrc:
export GNUTERM=aqua
On Linux, running a version of Octave without the bug mentioned above would be sufficient, as you're obviously running X11. I have gnuplot version 4.0.
