FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

aspect='equal' ignored when parasitic axis added with twinx/twiny · Issue #7654 · matplotlib/matplotlib · GitHub

Repository navigation

aspect='equal' ignored when parasitic axis added with twinx/twiny #7654

Closed as not planned

Description

Consider an axis with equal aspect ratio

from matplotlib import pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(111, aspect='equal')
ax1.grid()
plt.show()


Adding a parasitic axis with twinx() causes the plot to completely ignore aspect='equal'

from matplotlib import pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(111, aspect='equal')
ax1.grid()
ax2 = ax1.twinx()
plt.show()


Creating the primary axis with the keyword argument adjustable='box-forced' causes it to obey aspect='equal' but the parasitic axis does not.

from matplotlib import pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(111, adjustable='box-forced', aspect='equal')
ax1.grid()
ax2 = ax1.twinx()
plt.show()


Interestingly, everything works if the primary axis is created with host_subplot (note adjustable='box-forced' is still required). However, it seems to be prone to a similar issue to #7648 if figure.autolayout is set

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import host_subplot

fig = plt.figure()
ax1 = host_subplot(111, adjustable='box-forced', aspect='equal')
ax1.grid()
ax2 = ax1.twinx()
plt.show()

Platform: Windows 7
matplotlib: 1.5.3
python: 2.7.12

Activity

  1. added this to the milestone on Dec 21, 2016
  2. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Dec 21, 2016
  3. efiring commented on Dec 21, 2016

    Member

    Two comments related to this:

    1. 'box-forced' is inherently designed to break things. I have always maintained it was a bad idea. The best that can be said for it is that inclusion of the word 'forced' should warn the user to expect breakage. Some things will work, others won't. You are dealing with an over-determined system, so things will work only if all constraints turn out to be consistent.
    2. Your statement that "Adding a parasitic axis with twinx() causes the plot to completely ignore aspect='equal'" is not correct. The original axis still has a data aspect ratio of 1, which it is achieving by adjusting the data limits. twinx turns on axis sharing, which incompatible with aspect ratio control unless the adjustable is 'datalim'.

    We used to have a warning when the adjustable parameter was switched from 'box' to 'datalim' in this case. It is presently commented out. I think we need to uncomment it, and maybe even give it a longer explanation.

  4. modified the milestones: , on May 3, 2017
  5. modified the milestones: , on Oct 9, 2017
  6. efiring commented on Jan 26, 2018

    Member

    This is partly addressed by #10033, but it looks like more can be done. Instead of setting adjustable to 'datalim' on twinned axes, I think that it would be possible to check at drawing time whether the aspect ratio is specified for more than a single axes in a twinned pair, and switch to datalim only in that case. A 'box' adjustable should work for twinned axes with only one aspect ratio specified; or perhaps also if specified aspect ratios are identical.

  7. self-assigned this
    on Jan 26, 2018
  8. Dhrumil0 commented on Mar 14, 2018

    I was investigating a fix for this bug and even after the partial changes made by 10033 there still seem to be issues and I need clarification on how it's supposed to behave.

    1. What should the adjustable be when an axes and its twin both have aspect set to 'auto'?

    2. What if the aspects for both axes are the same? Should the adjustable be 'box' in these cases?

    3. What should happen in cases where the aspects are different like 'auto' and 'equal'? I tried to set this to datalim in the drawing time but I noticed that the current bug still persists with one of the axis going to 0.8 and the other one going to 1.0. Is this expected?

  9. github-actions commented on Apr 4, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  10. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesstatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL