Skip to content

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

Closed as not planned
@ndeadly

Description

@ndeadly

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()

figure_1-5


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()

figure_1-6


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()

figure_1-7


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()

figure_1-8

Platform: Windows 7
matplotlib: 1.5.3
python: 2.7.12

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