bugGNU Octave - Bugs: bug #49494, rescaling axes does not modify...

 
 

bug #49494: rescaling axes does not modify gca.ylim

Submitted by:  Clinton Winant <cwinant>
Submitted on:  Mon 31 Oct 2016 08:01:05 PM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Clinton WinantOpen/Closed: Open
Release: 4.2.1Operating 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 28 Aug 2017 06:34:14 PM UTC, comment #6:

Posted to the mailing list, not the tracker:

I confirm that with the change from 4.2.0 to 4.2.1 drawnow no longer
"fixes" the problem. To be sure we are all on the same page, the OP was to
point out that in this case, when a rescale occurs because of a forced
change in ytickmode, the ylimits in gca are not updated. I think they
ought to be, or at least there needs to be a way (as in 4.2.0 with drawnow)
to force refreshing values in gca, otherwise locating text after the
rescale is unreliable. Unfortunately I do not have easy access to matlab,
or I would be able to report how the same script works there.

I would very much like to help this effort (and octave in general). Please
let me know how I can support you.

This may be a good place to thank developers for all the additions to
4.2.1, notable rhe new availability of opengl through ssh tunneling. Way
to go!

John W. Eaton <jwe>
Project Administrator
Tue 07 Mar 2017 03:52:44 PM UTC, comment #5:

I am not sure why inserting "drawnow" helped in that specific RC. It no longer changes anything for me, too. Sorry that I gave wrong information. I was under the impression that "drawnow" would trigger an update of all graphics properties.

I also tried in Windows and got the same result as the OP.

The example in comment #0 works if either "ytick" or "ytickmode" is set before the last call of "plot". So maybe both should update the axis limits when changed. I can provide a changeset if this is the case.
Do we really want that the axes limits change in that case? Or is that the bug?

I had to slightly modify your script so that it could run in Matlab:

I get the same results when I execute the script line by line.

Markus Mützel <mmuetzel>
Project Member
Sun 05 Mar 2017 09:12:12 PM UTC, comment #4:

Drawnow has no effect for me and I am pretty sure that it should not be necessary here, I don't know that an axes object has to be rendered (that is what drawnow forces) for its properties to be right (for ui* objects it is another matter).
Further more I see the reported behavior wether I run the code as a script or paste it in the command window. In the latter situation Octave returns after each command and it should be equivalent to calling drawnow.

What I see here is that changing the "ytickmode" property doesn't force limits to be updated. Octave needs another object to be added (here the text object) to have the axes limits recomputed.
What does Matlab do/return executing the script below?

Pantxo Diribarne <pantxo>
Project Member
Mon 07 Nov 2016 09:41:47 AM UTC, comment #3:

I wouldn't consider this a workaround but the proper way to do it.
AFAIU, Octave (and Matlab) buffers commands that change graphics settings and executes them all at once when it deems it necessary or when the user calls drawnow. This is probably done to improve performance instead of calling all the necessary update function after each change of any property.

That said, you don't have to call "drawnow" everytime after you changed the graphics properties. Octave will update the properties when it deems it necessary.
However, you should always call "drawnow" (or a function that calls "drawnow" such as "pause") before getting properties of graphics if you expect to get updated values.

Markus Mützel <mmuetzel>
Project Member
Sat 05 Nov 2016 06:11:03 PM UTC, comment #2:

Using drawnow is a good workaround (works for me in 4.2.0-rc3), but I don't understand the logic? Surely any call to set(gca,..) ought to update all gca properties, particularly if that call changes those properties?

An example of how illogical this is is to include a pause statement before the sgca=get(gca) command (but no drawnow). In that case the program works correctly (since pause forced drawnow), and we have a program that behaves differently, depending on whether there is a pause or not!!

Is the current rule that drawnow should be called anytime the current axes properties are modified?

Clinton Winant <cwinant>
Sat 05 Nov 2016 01:37:40 PM UTC, comment #1:

You are missing a "drawnow" before line 15 of your script to make sure you are getting the updated axis limits.

This did not help for me in 4.0.3. But with that command added, it works as expected in Octave 4.2.0-rc3.

Markus Mützel <mmuetzel>
Project Member
Mon 31 Oct 2016 08:01:05 PM UTC, original submission:

The enclosed script plots a straight line twice. Both the script and resulting figure are attached. In the right hand plot, the y-axis tick mode has been set to manual. Since the right and left plots are not the same, I conclude that the y-axis has been rescaled by the set(gca... call. However a subsequent call to gca shows that ylim is the same for both plots. As a result the line "rescale" is placed correctly in only the left hand plot.
Ubuntu 16.04 gl2ps 1.3.8

Clinton Winant <cwinant>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #38848:  debug_rescale.m added by cwinant (612B - text/x-objcsrc)
file #38849:  debug_rescale.eps added by cwinant (8KiB - image/x-eps)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by pantxo (Posted a comment)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by mmuetzel (Posted a comment)
  • -unavailable- added by cwinant (Submitted the item)
  • -unavailable- added by cwinant
  •  

    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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 07 Mar 2017 03:52:44 PM UTCmmuetzelRelease4.2.0=>4.2.1
      Operating SystemGNU/Linux=>Any
    Thu 17 Nov 2016 03:59:56 AM UTCmtmillerRelease4.2.0-rc2=>4.2.0
    Mon 31 Oct 2016 08:01:05 PM UTCcwinantAttached File-=>Added debug_rescale.m, #38848
      Attached File-=>Added debug_rescale.eps, #38849
      Carbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1