Behavior of subplot
Michael D. Godfrey
godfrey at isl.stanford.edu
Mon Feb 9 16:32:00 CST 2009
I used an old function that contained subplot calls
with the current development Octave. It took a while
to recover the old behavior. The example below shows
what seems to me counter intuitive behavior:
hold off
x = [0:.1:10];
sx = sin(x);
cx = cos(x);
for k=1:3
axis([1,10,-1,1]);
subplot(2,3,k);
plot(x, sx);
axis([1,20,-1,1]);
subplot(2,3,3+k);
plot(x, 10*sx);
endfor;
====================================
For me the resulting six plots have the following properties:
Plots 1, 2, 3 (top row) xscale: 1:20, yscale: -1:+1
Plots 4 and 5: xscale:1:10, yscale: -1:+1
Plot 6: xscale: 0:10; yscale: -10:+10
======================================
For me, predictable results could only be obtained by using
the sequence:
subplot()
hold on
axis()
plot()
Also, I noticed that the behavior if the commands were entered
at the Octave prompt is different from the result of executing
them from a script. What happens is that subsequent subplot
commands "overwrite" the displayed result of a previous command.
Finally, two minor points:
1. The spacing between the rows is now such that the xlabels for
row 1 overlap the titles for row 2.
2. The bounding box of the output Postscript truncates the left
side of the plot. (I reported the bounding box problem earlier,
this is just another case.)
Michael Godfrey
More information about the Bug-octave
mailing list