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.

Submitted by:  Daisuke TAKAGO <takago>
Submitted on:  Tue 07 Jan 2014 06:09:20 AM UTC  
 
Category: Plotting with OpenGLSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Daisuke TAKAGOOpen/Closed: Closed
Release: 3.8.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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>
Project Administrator
Mon 09 Feb 2015 07:54:56 PM UTC, comment #14:

The patch works very well.

A few things before committing.

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>
Project 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>
Project 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>
Project 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:NM;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

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

Rik <rik5>
Project 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>
Project 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>
Project 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>
Project 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>
Project 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)

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

Pantxo Diribarne <pantxo>
Project 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>
Project Administrator
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>
Project 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 File(s):
   
   
Comment:
   

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

 

Digest:
   bug dependencies.

Digest:
   bug dependencies.

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 12 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 28 Sep 2015 02:44:52 PM UTCsiko1056StatusPatch Submitted=>Fixed
    Mon 09 Feb 2015 10:25:06 PM UTCpantxoOpen/ClosedOpen=>Closed
    Sun 08 Feb 2015 04:30:03 PM UTCbpabbottStatusConfirmed=>Patch Submitted
    Sun 08 Feb 2015 12:36:29 PM UTCpantxoAttached File-=>Added fix_subplot.patch, #33031
    Thu 31 Jul 2014 09:50:03 PM UTCandy1978Dependencies-=>bugs #42033 is dependent
    Mon 07 Apr 2014 06:33:12 PM UTCmtmillerDependencies-=>bugs #42063 is dependent
    Mon 07 Apr 2014 02:03:02 PM UTCrik5Dependencies-=>Depends on bugs #31610
    Thu 03 Apr 2014 07:49:02 PM UTCmtmillerItem GroupIncorrect Result=>Regression
      Operating SystemGNU/Linux=>Any
    Thu 03 Apr 2014 07:47:54 PM UTCmtmillerDependencies-=>bugs #42030 is dependent
    Tue 07 Jan 2014 07:59:44 PM UTCrik5StatusNone=>Confirmed
      Carbon-Copy-=>Added bpabbott

    Back to the top


    Powered by Savane 3.1-cleanup1