Skip to content

Add helper for setting axis limits in facetgrid #7046

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

Merged
merged 6 commits into from
Sep 25, 2022

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Sep 16, 2022

This PR adds a helper method that sets the same axis limits for all plots in a facetgrid.
Helpful when

  • wanting specific limits for all plots.
  • you want to make sure all data is visible by simply using the method without any inputs. Which is not certain if sharex/sharey isn't used, relevant when using 3d plots as they don't work.

Split up from #6778.

Copy link
Collaborator

@mathause mathause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment but I am also fine to merge as is.

Comment on lines 494 to 502
# Find the plot with the largest xlim values:
for ax in self.axes.flat:
get_lim: None | Callable[[], tuple[float, float]] = getattr(
ax, f"get_{k}lim", None
)
if get_lim:
l0, l1 = get_lim()
l0_old, l1_old = lims_largest[k]
lims_largest[k] = (min(l0, l0_old), max(l1, l1_old))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could potentially avoid some dict lookups and only assign them at the end - but I don't think it really matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not seeing what you're seeing. Feel free to push a commit if you like.

@Illviljan
Copy link
Contributor Author

Thanks @mathause! I'll merge this in a few days.

@Illviljan Illviljan added the plan to merge Final call for comments label Sep 23, 2022
@headtr1ck
Copy link
Collaborator

You don't need to specify int | float type, only float works :)

@Illviljan Illviljan merged commit 968443c into pydata:main Sep 25, 2022
Copy link
Collaborator

@keewis keewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit late, but I've got a few comments that might be good to address. The outdated parameter types should definitely be updated but I won't insist on renaming the variables.

@Illviljan
Copy link
Contributor Author

To be continued in #7082.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments topic-plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants