GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — zooming problem on figures with shared axes · Issue #2790 · matplotlib/matplotlib

zooming problem on figures with shared axes #2790

New issue
Copy link
New issue
Copy link
Closed
Closed
zooming problem on figures with shared axes#2790
Copy link
Assignees
efiring
Labels
status: confirmed bug

Description

@jfmoulin
jfmoulin
opened on Feb 5, 2014
Issue body actions

Hi!

I am trying to use axes shared across different figures and run into a funny effect when I resize one of the windows.
If I do:

import pylab as p
a0 = p.subplot(121) 
p.imshow(p.rand(100,100))
a1 = p.subplot(122,sharex=a0,sharey=a0)
p.imshow(p.rand(100,100)**2)
p.figure()
a2 = p.subplot(121,sharex=a0,sharey=a0)
p.imshow(p.rand(100,100)**3)

zooming into one of the axes does as expected: the other two follow.
However, when I resize one of the windows, all three axes zoom out completely (and not in one jump, it looks like seeing the image would be slowly falling away...)

Interestingly if I close the figures my shell still keeps on doing stuff backstage: my cpu is 100% busy. I tried this both under Ipython and a normal python shell.
Under Ipython a ctrl-C leads to the following traceback.

Original exception was:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtk.py", line 435, in expose_event
    self._render_figure(self._pixmap, w, h)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_gtkagg.py", line 84, in _render_figure
    FigureCanvasAgg.draw(self)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 451, in draw
    self.figure.draw(self.renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/figure.py", line 1034, in draw
    func(*args)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.py", line 2086, in draw
    a.draw(renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/artist.py", line 55, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 1093, in draw
    renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axis.py", line 1042, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/text.py", line 757, in get_window_extent
    bbox = bbox.translated(x, y)

thanks in advance!
JF

Activity

Next
  1. tacaswell
    added
    confirmed bug
    on Mar 20, 2014
  2. tacaswell
    added this to the v1.4.x milestone on Mar 20, 2014
  3. tacaswell commented on Mar 20, 2014

    @tacaswell
    tacaswell
    on Mar 20, 2014
    Member
    More actions

    That is a fun bug and can confirm it on master.

    This so probably something subtle deep in the callback code so I am tagging this as 1.4.x (instead of 1.4.0).

  4. WeatherGod commented on Mar 20, 2014

    @WeatherGod
    WeatherGod
    on Mar 20, 2014
    Member
    More actions

    Perhaps there is a subtle assumption that shared axes must be on the same
    figure. Aren't callbacks tied to the figure object? With the weakrefs in
    the callback architecture, I would wonder if closing out figures that have
    shared axes between them caused some sort of "detached circular reference"
    issue preventing the axes and callbacks from being garbage collected.

  5. tacaswell commented on Mar 20, 2014

    @tacaswell
    tacaswell
    on Mar 20, 2014
    Member
    More actions

    This does not involve closing windows, just resizing them.

  6. WeatherGod commented on Mar 20, 2014

    @WeatherGod
    WeatherGod
    on Mar 20, 2014
    Member
    More actions

    Except for the part where it does: "Interestingly if I close the figures my
    shell still keeps on doing stuff backstage"

  7. tacaswell commented on Mar 20, 2014

    @tacaswell
    tacaswell
    on Mar 20, 2014
    Member
    More actions

    Fair enough, but that is well after the bug has been triggered, I would classify that as a symptom rather than a cause.

    After re-sizing zooming also does not work correctly.

  8. tacaswell
    modified the milestones: v1.4.x, This milestone has been deleted on Feb 7, 2015
  9. tacaswell commented on Jul 17, 2015

    @tacaswell
    tacaswell
    on Jul 17, 2015
    Member
    More actions

    This can be solved the same way as #1325

    The following works as expected:

    import matplotlib.pyplot as plt
    
    fig0 = plt.figure()
    a0 = fig0.add_subplot(121)
    a0.set_adjustable('box-forced')
    a0.imshow(p.rand(100, 100))
    
    a1 = fig0.add_subplot(122, sharex=a0, sharey=a0)
    a1.set_adjustable('box-forced')
    a1.imshow(p.rand(100, 100)**2)
    
    
    fig1 = plt.figure()
    a2 = fig1.add_subplot(121, sharex=a0, sharey=a0)
    a2.set_adjustable('box-forced')
    
    a2.imshow(p.rand(100, 100)**3)

    The key is the ax.set_adjustable('box-forced').

  10. tacaswell
    closed this as completedon Jul 17, 2015
  11. efiring commented on Nov 12, 2015

    @efiring
    efiring
    on Nov 12, 2015
    Member
    More actions

    @tacaswell, your example above (just the first figure part) works only when the image domains are identical; for example, if you clear the second axes and then call imshow with np.random.rand(20,20), the first image will show only its 20x20 subarray.

  12. mdboom commented on Nov 12, 2015

    @mdboom
    mdboom
    on Nov 12, 2015
    Member
    More actions

    @efiring: Should we reopen this, then?

  13. 4 remaining items

  14. efiring
    added
    status: needs review
    on May 22, 2016
  15. efiring commented on May 22, 2016

    @efiring
    efiring
    on May 22, 2016
    Member
    More actions

    Even though we now have an example of sharing in different figures, the bug remains as originally described in this issue, complete with 100% CPU after closing the windows.

    Regardless of how the endless loop is arising, the underlying problem is a fundamental conflict between locking together the x and y limits and the aspect ratio between axes in two figures when the figure aspect ratio is not identical. This is just one of the examples of where aspect ratio handling and sharing runs into the problem of over-specification, which is the reason I never liked the box_forced option--it only works under restrictive conditions.

  16. efiring
    modified the milestones: This milestone has been deleted, v1.5.0 on Aug 1, 2016
  17. QuLogic
    modified the milestones: This milestone has been deleted, This milestone has been deleted on May 3, 2017
  18. efiring
    added a commit that references this issue on Jun 4, 2017

    BUG: raise ValueError if sharex, sharey point to a different figure

    This issue will close once commit bdd06dd is merged into the 'main' branch.
    bdd06dd
  19. tacaswell
    modified the milestones: This milestone has been deleted, This milestone has been deleted on Oct 9, 2017
  20. jklymak commented on Aug 17, 2018

    @jklymak
    jklymak
    on Aug 17, 2018
    Member
    More actions

    I don't see that this is a problem anymore on master. I'm guessing recent work has fixed this...

  21. jklymak
    closed this as completedon Aug 17, 2018
  22. jklymak
    removed
    status: needs review
    on Aug 17, 2018
  23. story645
    removed this from the future releases milestone on Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @efiring
    efiring

Labels

status: confirmed bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.