Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position.
Code for reproduction
importmatplotlib.pyplotaspltfig,ax=plt.subplots()ax.set_position([0.2,0.2,0.5,0.5])ax2=ax.twinx()plt.show()
Actual outcome
I note thatax.get_position(original=True)
andax.get_position(original=False)
both give the same answer.
I also note that the same issue occurs forax.twiny()
.
Expected outcome
This expected outcome can be obtained by adding the line
ax2.set_position(ax.get_position())
after callingax2=ax.twinx()
. Alternatively, it can be obtained by callingax.set_position
after callingax.twinx
.
However, I would expecttwinx
to automatically inherit the position of the parent Axes, rather than draw the new Axes in an unrelated location.
Operating system
Windows 10
Matplotlib Version
3.4.2
Matplotlib Backend
TkAgg
Python version
3.9.4
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response