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

Rename Plot.configure -> Plot.layout, add Plot.share, and modify Plot.layout parameters #2954

Merged
merged 8 commits into from
Aug 13, 2022

Conversation

mwaskom
Copy link
Owner

@mwaskom mwaskom commented Aug 13, 2022

A few important API changes here:

  • Plot.configure has been renamed to Plot.layout. It's shorter and better focused on what this method is about.
  • The sharex/sharey parameters have moved out of this method and into a new Plot.share method. I expect that this method will eventually generalize to other variables (i.e., allowing different color scales in subplots), but that's currently blocked on having a better story for legend configuration.
  • The figsize parameter in Plot.configure/Plot.layout has been shortened to just size.
  • An algo parameter has been added to Plot.layout, accepting "tight", "constrained", or None.

This PR has an additional tweak to fact that legends are currently not visible in an interactive pyplot window. When calling Plot.show, the legend will be right-aligned with the edge of the subplots, rather than left-aligned with it. This means that it will overlap the figure content, which is regrettable, but I don't know of a better non-hacky solution until matplotlib's layout algorithms understand figure legends.

When calling Plot.save, it is currently necessary to manually specify bbox_inches="tight" if you have a legend.

I expect that some of these decisions are temporary. In particular:

  • I hope that we have a better solution to controlling where the legend goes and whether it's visible by default in all relevant contexts.
  • I would like there to be a better automatic sizing and perhaps more convenient (subplot-based) size parameters. That's something that could quite possibly change in backwards incompatible ways across future releases.
  • I expect to add more parameters to Plot.layout for additional customization, but am not certain about the best API yet.

@mwaskom mwaskom added this to the v0.12.0 milestone Aug 13, 2022
@codecov
Copy link

codecov bot commented Aug 13, 2022

Codecov Report

Merging #2954 (9971081) into master (ae9080d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2954   +/-   ##
=======================================
  Coverage   98.30%   98.31%           
=======================================
  Files          69       69           
  Lines       23004    23064   +60     
=======================================
+ Hits        22615    22675   +60     
  Misses        389      389           
Impacted Files Coverage Δ
seaborn/_core/plot.py 97.38% <100.00%> (+0.05%) ⬆️
tests/_core/test_plot.py 98.58% <100.00%> (+0.01%) ⬆️
tests/test_distributions.py 99.79% <0.00%> (+<0.01%) ⬆️
tests/test_axisgrid.py 99.38% <0.00%> (+0.01%) ⬆️
seaborn/axisgrid.py 97.20% <0.00%> (+0.01%) ⬆️

@mwaskom mwaskom merged commit b5c4c35 into master Aug 13, 2022
@mwaskom mwaskom deleted the plot/layout branch August 13, 2022 22:02
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