Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharex or sharey with aspect=equal affects axis limits #7621

Closed
godaygo opened this issue Dec 12, 2016 · 4 comments
Closed

sharex or sharey with aspect=equal affects axis limits #7621

godaygo opened this issue Dec 12, 2016 · 4 comments
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action

Comments

@godaygo
Copy link

godaygo commented Dec 12, 2016

When aspect='equal' and sharex/sharey are used together, they affect the axis limits, and I can not precisely set them.

fig = plt.figure()

ax1 = fig.add_subplot(1,2,1)
ax2 = fig.add_subplot(1,2,2, sharey=ax1)

ax1.plot([.1, .5, .9], [.1, .5, .9], 'o')
ax2.plot([.1, .5, .9], [.1, .5, .9], 'o')

ax1.axis([0, 1, 0, 1])
ax2.axis([0, 1, 0, 1])

ax1.set_xticks([0, .2, .4, .6, .8, 1])
ax2.set_xticks([0, .2, .4, .6, .8, 1])

plt.show()

figure_1-by

Also sharex and sharey behaves differently. Above picture was for sharey, below is for sharex:
figure_1-bx

When I use one of them everything looks fine, with aspect=equal, without share:

fig = plt.figure()

ax1 = fig.add_subplot(1,2,1, aspect='equal')
ax2 = fig.add_subplot(1,2,2, aspect='equal')

ax1.plot([.1, .5, .9], [.1, .5, .9], 'o')
ax2.plot([.1, .5, .9], [.1, .5, .9], 'o')

ax1.axis([0, 1, 0, 1])
ax2.axis([0, 1, 0, 1])

ax1.set_xticks([0, .2, .4, .6, .8, 1])
ax2.set_xticks([0, .2, .4, .6, .8, 1])

plt.show()

figure_1-g
without aspect=equal, with sharey:
figure_gy

Also the trouble is the same for set_aspect and axis('equal').

matplotlib 1.5.3.
python 3.5.2

@godaygo godaygo changed the title sharex or sharey affects axis limits sharex or sharey with aspect=equal affects axis limits Dec 12, 2016
@tacaswell
Copy link
Member

This is because you are trying to over-constrain the system. You essentially have the equations

x_range = C1
y_range = C2
x_range =  λ * y_range

which clearly can not be solved if C1 = λ*C2 .

@godaygo
Copy link
Author

godaygo commented Dec 12, 2016

@tacaswell Sorry, I can not fully understand your idea. 'equal' means that the length of line segment will be the same on x and y, and share only shares. How they both here affect axis limits?

About over-determined systems, as I remember they can have zero, one, or infinity number of solutions. Here as I see, the solution is: x_range=[0, 1]; y_range=[0, 1]; λ =1. But as I say I don't understand how does this situation relate with over-determined systems? I have YAxis of ax2 to share with YAxis of ax1. The aspect must be equal (the corresponding lengths on axes) and nothing more. But the Xaxis limits become broken.

I think that the picture should be (like with no sharing):
image

@godaygo
Copy link
Author

godaygo commented Dec 21, 2016

@tacaswell Accoording to this issue #7654. If I use adjustable='box-forced' kwarg, everything works fine as expected.

fig = plt.figure()
ax1 = fig.add_subplot(121, adjustable='box-forced', aspect='equal')
ax2 = fig.add_subplot(122, adjustable='box-forced', aspect='equal', sharey=ax1)

ax1.plot([.1, .5, .9], [.1, .5, .9], 'o')
ax2.plot([.1, .5, .9], [.1, .5, .9], 'o')

ax1.axis([0, 1, 0, 1])
ax2.axis([0, 1, 0, 1])

ax1.set_xticks([0, .2, .4, .6, .8, 1])
ax2.set_xticks([0, .2, .4, .6, .8, 1])

plt.show()

@github-actions
Copy link

github-actions bot commented Apr 3, 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!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 3, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2023
@rcomer rcomer added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

3 participants