bugGNU Octave - Bugs: bug #61532, "Automatic limits for current...

 
 

bug #61532: "Automatic limits for current axis" button doesn't respect "axis tight"

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Tue 23 Nov 2021 02:30:08 PM UTC  
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Patch Submitted Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  Open
Release:  dev 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)

Mon 29 Nov 2021 10:09:30 PM UTC, comment #6: 

Thanks for the prompt actions Panxto.

I'll try the patch somewhere this week.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 29 Nov 2021 09:50:23 PM UTC, comment #5: 

I attached an updated version of the patch. I think the documentation would benefit from being reread by a better english speaker, but apart from that the new feature works well AFAICS.

(file #52389)

Pantxo Diribarne <pantxo>
Project Member
Fri 26 Nov 2021 05:16:56 PM UTC, comment #4: 

I attached a preliminary patch that adds and implements the x(y,z)limitmethod properties. TODO: document the new property and use it in the `axis` function.

(file #52355)

Pantxo Diribarne <pantxo>
Project Member
Wed 24 Nov 2021 06:22:49 PM UTC, comment #3: 

I think this has already been partly discussed in the past, but I can't find the bug report.

For anything other than "axis auto", Octave sets custom "x(y,z)lim" and consequently "x(y,z)limmode" becomes manual. In other words auto limits cannot be tight.

According to Matlab's documentation for axis [1], e.g. the "tight" option should leave "x(y,z)limmode" unchanged and instead change the "x(y,z)limitmethod" property to "tight".

We thus need to add and implement "x(y,z)limitmethod" properties [2] and let the axes graphics object compute limits accordingly.

Changing release to "dev" since this looks like an important change.

[1] https://nl.mathworks.com/help/matlab/ref/axis.html#buk989s-1-style
[2] https://nl.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html#budumk7_sep_mw_7623f06d-1795-480f-b113-e08ce76e79d5

Pantxo Diribarne <pantxo>
Project Member
Tue 23 Nov 2021 05:15:05 PM UTC, comment #2: 

Indeed, I missed mentioning "axis tight" after the plot command :-)
Thanks for spotting that.

What I think should happen is s/th along these lines:

  • The first time one of the zoom buttons is clicked after any other plot command or button click, the current axis limits are saved somewhere. Then a "tight" or "auto" setting wouldn't matter, just as Matlab does and as -I think- an unwary user would expect;
  • Upon (possibly repeatedly) zooming out or upon clicking the "Automatic limits" button, the plot zooms out until the saved axis limits completely fill the (sub)plot box; i.e., the original axis limits are restored.
  • Any intermediate axis limits or view setting other than zooming in/out/restore (e.g., axis auto / set (<handle>, xlim, [ ...]) / etc.) wipes or resets the saved axis settings.

As to other properties requiring "stickyness", I currently have no idea except tilting (rotating). Any 2D plot can be tilted (rotated), I can imagine that after a lot of rotations a user loses track of up and down and wants to reset the plot to the original view angle.
I'd hope that once a solution is found for xlim/ylim, "stickyness" for other properties can be tackled in a similar fashion.

There's the old bug #44323 (also by me) about zooming in 3D plots, but for that case I think zooming out (or maybe better: changing camera position) beyond original axis limits could be quite useful for 3D plots.

Philip Nienhuis <philipnienhuis>
Project Member
Tue 23 Nov 2021 03:39:24 PM UTC, comment #1: 

Was an "axis tight" command missing from your "Steps to reproduce"?

If I'm reading scripts/plot/util/private/__add_default_menu__.m correctly, the "automatic limits" button just executes

axis (H, "auto")

for all axes in the current figure that aren't legends.  What can it do differently to respect the "axis tight" setting?

Should

axis (H, "auto")

by itself just not reset the "tight" setting?  Are there other properties that should also be "sticky"?

John W. Eaton <jwe>
Project Administrator
Tue 23 Nov 2021 02:30:08 PM UTC, original submission:  

(Admittedly merely cosmetic, but for complicated plots and esp. maps (mapping package) I find Octave's behavior quite annoying)

Steps to reproduce:

Type:
xm = 7; plot (-xm:xm, sin (-xm:xm)) 
==> Plot shows up

Zoom in somewhere in the plot (isn't even required)

Click "Automatic limits for current axis" button

==> Plot again has "loose" limits.

Same for Octave-5.2.0, so this is an old issue.

Matlab (I tested with r2014a & r2020b) does this "right", or maybe better: "as expected":
r2014a seems to have no "Automatic limits" button, but the "Zoom out" button, clicked often enough, in the end produces the original plot with tight axis limits.
r2020b's "Restore original view" does likewise.

Along the way, noted another incompatibility:
Octave allows zooming out much further than the original axis limits and behaves quite unpredictably at that. Sometimes (when clicking the zoom out button repeatedly) it suddenly zooms back in to original (loose) view, sometimes it zooms out two or three times and only then suddenly zooms back in to original (loose) view.
Matlab consistently zooms out until the original plot size is restored, tight or loose.

I had a look in axis.m, I think the relevant code there looks quite involved. Maybe easier fixed using hidden properties for original axis limits settings? ("original" meaning "before zooming in")

Philip Nienhuis <philipnienhuis>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52389:  bug61526-v2.patch added by pantxo (25KiB - text/x-patch)
file #52355:  bug61532.patch added by pantxo (15KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by philipnienhuis (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-29 pantxo Attached File- => Added bug61526-v2.patch, #52389
        StatusIn Progress => Patch Submitted
    2021-11-26 pantxo Attached File- => Added bug61532.patch, #52355
        StatusNone => In Progress
    2021-11-24 pantxo Release7.0.90 => dev
    2021-11-23 jwe Item GroupMatlab Compatibility => Incorrect Result
        Operating SystemMicrosoft Windows => Any

    Back to the top


    Powered by Savane 3.7