bugGNU Octave - Bugs: bug #41128, In fltk backend, subplot(M,N,n)...

 
 

bug #41128: In fltk backend, subplot(M,N,n) does not work in condition 4<M.

Submitter:  Daisuke TAKAGO <takago>
Submitted:  Tue 07 Jan 2014 06:09:20 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Daisuke TAKAGO Open/Closed:  * Closed
Release:  * 3.8.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 09 Feb 2015 10:25:06 PM UTC, comment #17: 

I pushed the updated changeset here: http://hg.savannah.gnu.org/hgweb/octave/rev/8064b5cdbc11

I will now close this report and look into the related ones. At least bug #40686, bug #43067, bug #43064, bug #43018, bug #42612, bug #42554, bug #42033, bug #41128, bug #40686, bug #39874

Pantxo Diribarne <pantxo>
Group Member
Mon 09 Feb 2015 08:21:48 PM UTC, comment #16: 

Thanks for the review.

I'll follow your recommendations.
About the appdata I added, "subplotposition" is also defined in  Matlab (undocumented as an internal), but "subplotouterposition" is not. So I agree that those are internals we should name as such.

Pantxo Diribarne <pantxo>
Group Member
Mon 09 Feb 2015 08:13:20 PM UTC, comment #15: 

To match other "internal-use-only" names, please use _subplotposition_, not just __subplotposition.

John W. Eaton <jwe>
Group administrator
Mon 09 Feb 2015 07:54:56 PM UTC, comment #14: 

The patch works very well.

A few things before committing.


align_axes = (align_axes | (! isscalar (index)));


I would use the short-circuit form of the or operator (||) above.

For the newly added appdata fields, I would use the internal prefix "__" on the names: "__subplotposition" and "__subplotouterposition".  This is Octave specific so we should leave the namespace open in case a programmer wants to use "subplotposition" as a field name.

At the bottom, we like to use two newlines between the keyword "endfunction" and the start of the %!demo or %!test block.

Rik <rik5>
Group administrator
Sun 08 Feb 2015 04:30:03 PM UTC, comment #13: 

I tried the patch with the stable branch. It applied cleanly, passed all tests, and all demos worked as expected.

I'm presently unable to build the default branch. Which is where I expect this changeset should be applied.

Ben Abbott <bpabbott>
Group Member
Sun 08 Feb 2015 12:36:29 PM UTC, comment #12: 

Hi,

I have attached a patch that fixes this bug for me:

  • the position computation (subplot_position) and update (subplot_align) routines have been completely rewritten
  • the "activepositionproperty" of subplots is now always "position"
  • if the "position" property is changed from outside subplot_align routine (e.g. by external colorbar or legend), the subplot size stops being updated.
  • I added tests.


I didn't notice serious regressions using gnuplot or OpenGl based toolkits. External colorbars and legends (see demos) are still not quite right.

If none has a strong opinion against the changes I brought, I'll push the patch.

(file #33031)

Pantxo Diribarne <pantxo>
Group Member
Tue 23 Dec 2014 10:18:48 AM UTC, comment #11: 

I've just discovered that this:

close all; M=5; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); pause; end

works fine. I have to press enter after each subplot, but at the end all subplots are there and there is no error at the octave prompt. If I remove the pause command I briefly see the 5 subplots, then the 4 first subplots disappear and I get the "line 0: function to plot expected" error. Maybe a race condition, IDK.

Anyway, that's a different bug. I'm happy to see we'll have a fix for for the FLTK backend soon.

-Deleted Account- <fjvazquezaraujo>
Mon 22 Dec 2014 05:14:48 PM UTC, comment #10: 

In discussions on the Octave Maintainers list, Pantxo is going to take a look at the subplot function in January.  Apparently code that used to make this work with FLTK was accidentally removed.

In the mean time, however, I can use gnuplot without trouble on your example of


close all; M=5; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end


I tried this with Octave 3.8.2 and also the development version.  The gnuplot version was 4.6.2.

Rik <rik5>
Group administrator
Mon 22 Dec 2014 08:23:28 AM UTC, comment #9: 

So, is there any way to plot more than 4 rows right now (well, for the last several months actually)? Falling back to gnuplot doesn't work either:

close all; M=5; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end

results in:

multiplot>
               ^
           line 0: function to plot expected

and only the last subplot is drawn.

-Deleted Account- <fjvazquezaraujo>
Wed 09 Jul 2014 05:36:13 PM UTC, comment #8: 

What I meant about the height of the blank
space is it is the normal height of a
subplot times M-4.

Michael Godfrey <godfrey>
Group Member
Wed 09 Jul 2014 03:32:55 PM UTC, comment #7: 

A note on subplots with M>4 using the current dev system:

The command:
  for n=1:N*M;subplot(M,N,n);plot(1:100);endfor

for N=4 and M > 4 results in 3 "correct" rows, then
blank space of height about M-4 and then a last
"correct" row.

Odd

Michael Godfrey <godfrey>
Group Member
Wed 09 Jul 2014 07:33:12 AM UTC, comment #6: 

Hi, just to note that I am seeing this problem trying out Octave for the first time with some of our old Matlab scripts, it's pretty frustrating and a fix would be much appreciated.

Jon Povey <jonpovey>
Mon 07 Apr 2014 02:13:44 PM UTC, comment #5: 

Another disadvantage of always using 'align' is that changing to an existing subplot, created with 'align', using the syntax 'subplot (M,N, idx)' often causes the axes to be replaced.

Rik <rik5>
Group administrator
Mon 07 Apr 2014 02:02:33 PM UTC, comment #4: 

According to Matlab documentation (http://www.mathworks.com/help/matlab/ref/subplot.html) the default is now to "align" plot boxes.  The actual "align" argument seems to be redundant because, aside from using a "position" vector argument, there is no way to not get aligning behavior.  When I use the extra argument 'align' with Octave then all of the examples in this bug report work.  So, maybe the thing to do is to change the default in Octave subplot.m from 'align_axes = false' to 'align_axes = true'.

There was a big discussion of the disadvantage of this, possibly overlapping text lables, in bug #31610.  Apparently, what Octave should be doing is setting up callbacks so that as the position of axes changes, due to adding titles or axis labels, the other plots will update.

Rik <rik5>
Group administrator
Sun 06 Apr 2014 03:10:35 PM UTC, comment #3: 

I think the main problem here is an inconsistency between the "outerposion" grid and the "postion" grid (see subplot_position()): the first has symmetric margins whereas the latter has right and top margins that depend on the row/col number.

When the number of rows/col is increased the computed "position" gets outside the computed "outerposition" area. This has two consequences:
 - the "position" may overlap with other axes which are then deleted. 
 - The "looseinset" property may be set to negative data which leads to those strange axes compressions you see in the following example (it is said to work well according to the OP but that is not what I observe)


close all; M=4; N=6; for n=1:N*M;subplot(M,N,n); plot(1:100); end


Is there a reason for not using "outerposition" as "activepositionproperty" in subplots?

Pantxo Diribarne <pantxo>
Group Member
Thu 03 Apr 2014 07:49:02 PM UTC, comment #2: 

Marking as regression because (as noted in bug #42030) these examples worked in version 3.6.4 with fltk. Also setting OS to Any because the duplicate report is from a Windows user.

Mike Miller <mtmiller>
Group Member
Tue 07 Jan 2014 07:59:44 PM UTC, comment #1: 

This bug is confirmed.  The problem is likely to be due to round-off error when calculating the positions of the subplots.

Rik <rik5>
Group administrator
Tue 07 Jan 2014 06:09:20 AM UTC, original submission:  

I found subplot(M,N,n) does not work in condition 4<M.
I confirmed this problem in both version 3.7.7+ and 3.8.0.
(this occurs only on fltk backend)

# EXAMPLE(work well)
close all; M=1; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=2; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=3; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=2; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=3; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=4; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=5; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=4; N=6; for n=1:N*M;subplot(M,N,n); plot(1:100); end

# EXAMPLE(Not work well)
close all; M=5; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=6; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=7; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end

# EXAMPLE(Not work well)
close all; M=5; N=1; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=5; N=2; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=5; N=3; for n=1:N*M;subplot(M,N,n); plot(1:100); end
close all; M=5; N=4; for n=1:N*M;subplot(M,N,n); plot(1:100); end

Daisuke TAKAGO <takago>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #33031:  fix_subplot.patch added by pantxo (18KiB - application/x-download)

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by fjvazquezaraujo (Posted a comment)
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by jonpovey (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by takago (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-28 siko1056 StatusPatch Submitted Fixed
    2015-02-09 pantxo Open/ClosedOpen Closed
    2015-02-08 bpabbott StatusConfirmed Patch Submitted
    2015-02-08 pantxo Attached File- Added fix_subplot.patch, #33031
    2014-07-31 andy1978 Dependencies- bugs #42033 is dependent
    2014-04-07 mtmiller Dependencies- bugs #42063 is dependent
    2014-04-07 rik5 Dependencies- Depends on bugs #31610
    2014-04-03 mtmiller Item GroupIncorrect Result Regression
        Operating SystemGNU/Linux Any
    2014-04-03 mtmiller Dependencies- bugs #42030 is dependent
    2014-01-07 rik5 StatusNone Confirmed
        Carbon-Copy- Added bpabbott

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code