Behavior of subplot

Ben Abbott bpabbott at mac.com
Mon Feb 9 19:44:32 CST 2009


On Feb 9, 2009, at 5:32 PM, Michael D. Godfrey wrote:

> 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()

I'm confused. The behavior you describe in your table is the same I  
get in both Octave (developers sources) and in Matlab.

What is it you had expected?

> 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.

I don' t understand what you refer to here.

> 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.)

I suspect this is due to a partial implementation of properties in the  
gnuplot backend. The position of ticklabels, axis labels, and the  
title are important to produce compatible behavior. In addition, the  
position of the axes themselves appear to be incorrect to me (this may  
be because of a difference in versions of gnuplot).

I was experimenting with some m-files to handle most of this for 2D  
plots, but ran into a problem with initialization of the axis  
ticklabels (actually we had discussed this in early January). As my c\c 
++ skills are pathetic I got frustrated and gave up :-(

In any event, I hope to have some time to continue work on the gnuplot  
backend in late February and early March. My short list is ...

(1) Have Octave handle positioning of the title, axes labels, and axes  
ticklabels for 2D plots (beyond experimenting, I haven't done anything  
worth while yet).
(2) Add listeners for many properties for 2D plots (I've implemented  
most of this in an m-file ... which should ultimately be implemented  
at a lower level).
(3) Plead with you/someone to take care of the initialization of the  
ticklabel initialization so that I can sleep at night ;-)

Ben






More information about the Bug-octave mailing list