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

Incompatibility with plt.subplots(..., sharey=True) #26

Closed
sholderbach opened this issue Sep 14, 2022 · 4 comments
Closed

Incompatibility with plt.subplots(..., sharey=True) #26

sholderbach opened this issue Sep 14, 2022 · 4 comments

Comments

@sholderbach
Copy link

As the drawcall updates the ylim using the sharey=True setting in matplotlib.pyplot.subplots() is not really useful to compare the weights of different matrices.

MRE:

mtx = logomaker.get_example_matrix('logomaker_logo_matrix')
fig, axs = plt.subplots(2, sharey=True)
logomaker.Logo(mtx * 2, ax=axs[0]) # Require a larger dynamic range
logomaker.Logo(mtx, ax=axs[1]) # ylims are updated to the last displayed range

Output:

grafik

Expected behavior:

If multiple logos with a shared y or x axes are drawn, the range accomodates the largest drawing to allow comparison of the magnitude.


matplotlib version used: 3.5.2

@liliblu
Copy link

liliblu commented Aug 9, 2023

I'm also running into this problem.
I'm getting around it by setting sharey=True, then saving the lowest ymin and highest ymax via ax.get_ylim() for each plot and finally setting ax.set_ylim(ymin, ymax) at the end of creating the figure. Hope that helps you too.

@atareen
Copy link
Collaborator

atareen commented Aug 21, 2023

Thank you @liliblu for the solution!

@sholderbach can you try the above please? If the solution works for you, please close the issue.

@jbkinney
Copy link
Owner

Thank you all for raising this issue, and sorry for the delay in addressing it. I've just fixed the auto-scaling in Logo() to account for the sister ax objects in each fig object that have coordinated limits via sharey=True or sharex=True (see lines 1058-1063 and 1072-1077 in Logo.py). I'm closing this issue now; please raise again if you find any problems.

@sholderbach
Copy link
Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants