Skip to content

ENH: Fix support for matplotlib's constrained_layout (#25261) #39394

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

Conversation

mdruiter
Copy link
Contributor

@mdruiter mdruiter commented Jan 25, 2021

@mdruiter
Copy link
Contributor Author

The failing tests seem totally unrelated!?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

pls add the test from the OP

@@ -227,7 +227,8 @@ def _grouped_plot_by_column(

byline = by[0] if len(by) == 1 else by
fig.suptitle(f"Boxplot grouped by {byline}")
fig.subplots_adjust(bottom=0.15, top=0.9, left=0.1, right=0.9, wspace=0.2)
if not hasattr(fig, "get_constrained_layout") or not fig.get_constrained_layout():
Copy link
Contributor

Choose a reason for hiding this comment

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

make a function for this
maybe_adjust_figure or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Hope this is what you had in mind.

@jreback jreback added the Visualization plotting label Jan 25, 2021
@mdruiter mdruiter requested a review from jreback January 26, 2021 14:07
@@ -341,7 +341,7 @@ Plotting
^^^^^^^^

- Bug in :func:`scatter_matrix` raising when 2d ``ax`` argument passed (:issue:`16253`)
-
- Support matplotlib's ``constrained_layout=True`` (:issue:`25261`)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you be slightly more verbose here. this allows passing this option right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change just prevents pandas from doing incompatible things when a figure has constrained_layout enabled.

@mdruiter mdruiter requested a review from jreback January 28, 2021 09:32
@jreback jreback added this to the 1.3 milestone Jan 28, 2021
@jreback jreback merged commit bdfaea4 into pandas-dev:master Jan 28, 2021
@jreback
Copy link
Contributor

jreback commented Jan 28, 2021

thanks @mdruiter very nice!

@mdruiter mdruiter deleted the Fix_support_for_matplotlib_s_constrained_layout_25261 branch January 29, 2021 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plotting: subplots_adjust prevents use of constrained_layout=True
2 participants