bugGNU Octave - Bugs: bug #59076, subplot replaces previously...

 
 

bug #59076: subplot replaces previously created axes

Submitted by:  Charles Praplan <charprap>
Submitted on:  Mon 07 Sep 2020 08:42:25 AM UTC  
 
Category:  Plotting Severity:  2 - Minor
Priority:  3 - Low Item Group:  Feature Request
Status:  Ready For Test Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.0.90 Operating 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)

Wed 23 Sep 2020 07:25:53 PM UTC, comment #9: 

Some tests were failing with that change. Sorry, I haven't tested before.
I reinstated the old logic with your new logic as the fallback (along the lines of comment #3):
https://hg.savannah.gnu.org/hgweb/octave/rev/396d3e1df78b

Markus Mützel <mmuetzel>
Project Member
Wed 23 Sep 2020 06:42:58 PM UTC, comment #8: 

@Markus: Thanks, I pushed the patch to stable.

Pantxo Diribarne <pantxo>
Project Member
Wed 23 Sep 2020 06:25:05 AM UTC, comment #7: 

The patch looks reasonably save to me. And we had multiple reports about similar issues in the past. So users seem to be affected by this issue in various situations.
So I'd say: Go ahead and push it on stable.

Markus Mützel <mmuetzel>
Project Member
Tue 22 Sep 2020 08:27:58 PM UTC, comment #6: 

@Markus: Sorry for the delay. The attached patch just adds the missing "all" you mentioned. I think the change is safe but is it reasonable to push it to stable at this stage of the release process or should it go to default? 

(file #49842)

Pantxo Diribarne <pantxo>
Project Member
Fri 11 Sep 2020 12:33:39 PM UTC, comment #5: 

Sounds good to me.

I also tested with "cla", "cla reset", and "reset(gca)". Nothing seems to rid the user appdata. So your new approach is probably save.

Markus Mützel <mmuetzel>
Project Member
Wed 09 Sep 2020 10:13:27 PM UTC, comment #4: 

>> I wonder if it would make sense to keep the old logic and add the new logic if the old one failed.


I think the old logic is broken since a subplot position may change, e.g. due to the addition of a large title, and the stored position is then made obsolete.

>> Also it might be clearer to add an "all" around "size (rcn) == [1 3]" in the condition.


Yes, I'll do that thanks for noticing.

>> But is it possible that an axes looses its appdata somehow? IIRC, e.g. "plot" resets about everything in an axes if hold is "off".


All the job is done by the newplot function: we retrieve the axes appdata before clearing all listeners and children. After that the orphaned clean axes is turned into a subplot again using "subplot (ROWS, COLS, INDEX, HAX)". 

Pantxo Diribarne <pantxo>
Project Member
Wed 09 Sep 2020 08:59:53 PM UTC, comment #3: 

I haven't tried your change yet. But it looks like it would do what I was imagining.

I wonder if it would make sense to keep the old logic and add the new logic if the old one failed.
Also it might be clearer to add an "all" around "size (rcn) == [1 3]" in the condition.

I haven't tried that yet either. But is it possible that an axes looses its appdata somehow? IIRC, e.g. "plot" resets about everything in an axes if hold is "off".
I wonder if there is a reason why Matlab chose to store that information in the axes' parent instead of in the axes itself.

Markus Mützel <mmuetzel>
Project Member
Mon 07 Sep 2020 08:07:03 PM UTC, comment #2: 

@Markus: I attached a patch that fixes the issue for me (but I didn't test much). I think that more or less follows the approach you proposed.

(file #49762)

Pantxo Diribarne <pantxo>
Project Member
Mon 07 Sep 2020 09:35:50 AM UTC, comment #1: 

Confirmed here.

Something leads to the positions of the existing axes and the axes that "subplot" wants to create not matching. That means that the following action (from the doc) is executed:

> Any previously existing axes that would be (partly) covered by the newly created axes are deleted.

The difference is only very minor. And I agree that the old axes should probably be reused.
There have been a bunch of similar bug reports in the past.

If I run your code in Matlab R2020a, the axes are reused (instead of replaced).
I see that the figure has the following user appdata:

>> getappdata(gcf)

ans =

  struct with fields:

    SubplotDefaultAxesLocation: [0.1300 0.1100 0.7750 0.8150]
              SubplotListeners: []
       SubplotListenersManager: [1×1 matlab.graphics.internal.SubplotListenersManager]
                  SubplotDirty: []
                   SubplotGrid: [2×1 Axes]

The two axes handles in "SubplotGrid" correspond to the two axes in the subplot.

AFAICS, Octave tries to recognize subplot axes "from scratch" each time it is called. It doesn't keep track of which axes are part of a "subplot" layout.
Maybe doing something similar in Octave would make it easier for "subplot" to recognize axes it could re-use (instead of replace).

In the meantime, you could call "subplot" with the handle to the existing axes (like you already wrote).

Markus Mützel <mmuetzel>
Project Member
Mon 07 Sep 2020 08:42:25 AM UTC, original submission:  

In the appended example, when calling subplot(2,1,1) at end of script, the subplot disappears as if subplot were called with the 'replace' option.

% If the subplot fct is called using an handle (subplot(sp1_handle) ), everything is ok.

This also happens with version 5.2.0.

Charles Praplan <charprap>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49842:  bug59076_2.patch added by pantxo (1KiB - text/x-patch)
file #49762:  bug59076.patch added by pantxo (1KiB - text/x-patch)
file #49751:  subplot_test_case.m added by charprap (517B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by charprap (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-23 pantxo StatusPatch Submitted => Ready For Test
    2020-09-23 mmuetzel Releasedev => 6.0.90
    2020-09-22 pantxo Attached File- => Added bug59076_2.patch, #49842
    2020-09-07 pantxo Attached File- => Added bug59076.patch, #49762
        StatusConfirmed => Patch Submitted
    2020-09-07 mmuetzel Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
        Item GroupNone => Feature Request
        StatusNone => Confirmed
        Release6.0.90 => dev
        Operating SystemMicrosoft Windows => Any
        Summarysubplot clears the plot => subplot replaces previously created axes
    2020-09-07 charprap Attached File- => Added subplot_test_case.m, #49751

    Back to the top


    Powered by Savane 3.5