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

Add extent to Plot.layout configuration #3552

Merged
merged 4 commits into from
Dec 9, 2023
Merged

Add extent to Plot.layout configuration #3552

merged 4 commits into from
Dec 9, 2023

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Nov 7, 2023

This PR adds the extent parameter to Plot.layout.

While part of incremental progress towards full fine-grained layout customization through Plot methods, this update also helps ease some temporary pains. Namely, it may be useful for keeping the legend "outside" of the plot when using Plot.show. Recall that the legend is set to be interior to the figure boundary when Plot.show is called — hence, when pyplot is used to display the plot — to avoid extending past the boundaries of the pyplot window:

(
    so.Plot(tips, x="total_bill", y="tip")
    .add(so.Dot(), label="Some dots")
    .show()
)

Setting the right boundary of the extent to <1 leaves room for the legend:

(
    so.Plot(tips, x="total_bill", y="tip")
    .add(so.Dot(), label="Some dots")
    .layout(extent=(0, 0, .8, 1))
    .show()
)

Getting the position right may require a little fiddling based on the width of the legend itself. This isn't a perfect fix for legend positioning in so.Plot, just workaround (as a special case of a generally-useful configuration).

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #3552 (596ad4f) into master (03d703b) will decrease coverage by 0.01%.
The diff coverage is 95.12%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3552      +/-   ##
==========================================
- Coverage   98.52%   98.52%   -0.01%     
==========================================
  Files          75       75              
  Lines       24668    24701      +33     
==========================================
+ Hits        24305    24336      +31     
- Misses        363      365       +2     
Files Coverage Δ
seaborn/_compat.py 59.74% <100.00%> (+4.02%) ⬆️
seaborn/_core/subplots.py 100.00% <ø> (ø)
tests/_core/test_plot.py 98.83% <100.00%> (+0.01%) ⬆️
seaborn/_core/plot.py 99.15% <86.66%> (-0.24%) ⬇️

@mwaskom mwaskom merged commit 056413d into master Dec 9, 2023
12 of 13 checks passed
@mwaskom mwaskom deleted the plot/layout_rect branch December 9, 2023 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant