-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Don't ignore figsize in df.boxplot #16445
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
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3df3a2e
Propagate the figsize via the rcParams, since matplotlib doesn't allo…
0c2913b
Update what's new for v0.21.0 and use rc_context() to temporarily cha…
50b4b23
Merge with upstream.
b9a461b
Move bug fix from 0.21.0 whatsnew to 0.20.2.
4915302
Allow passing in an rc to _gca() instead of just figsize, and added a…
bab6ea2
Fix style violations.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,18 @@ def _get_standard_kind(kind): | |
return {'density': 'kde'}.get(kind, kind) | ||
|
||
|
||
def _gca(): | ||
def _gca(figsize=None): | ||
import matplotlib.pyplot as plt | ||
return plt.gca() | ||
if figsize is not None: | ||
# No way of passing in figsize via gca() call so temporarily change the | ||
# defaults so that when it calls figure() it uses our figsize. | ||
old_figsize = plt.rcParams.get('figure.figsize') | ||
plt.rcParams['figure.figsize'] = figsize | ||
try: | ||
return plt.gca() | ||
finally: | ||
if figsize is not None: | ||
plt.rcParams['figure.figsize'] = old_figsize | ||
|
||
|
||
def _gcf(): | ||
|
@@ -1871,14 +1880,8 @@ def plot_series(data, kind='line', ax=None, # Series unique | |
**kwds): | ||
|
||
import matplotlib.pyplot as plt | ||
""" | ||
If no axes is specified, check whether there are existing figures | ||
If there is no existing figures, _gca() will | ||
create a figure with the default figsize, causing the figsize=parameter to | ||
be ignored. | ||
""" | ||
if ax is None and len(plt.get_fignums()) > 0: | ||
ax = _gca() | ||
ax = _gca(figsize) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would maybe revert this change, since we pass figsize through to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed that, thanks. Changing it back. |
||
ax = MPLPlot._get_ax_layer(ax) | ||
return _plot(data, kind=kind, ax=ax, | ||
figsize=figsize, use_index=use_index, title=title, | ||
|
@@ -2006,7 +2009,7 @@ def plot_group(keys, values, ax): | |
"'by' is None") | ||
|
||
if ax is None: | ||
ax = _gca() | ||
ax = _gca(figsize) | ||
data = data._get_numeric_data() | ||
if columns is None: | ||
columns = data.columns | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change
_gca
to take an optional dictionary? So likethat way, we aren't limited to just
figsize
when we call gca. You'd call it likeax = _gca({'figure.figsize': figsize})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that. Note that I can't unconditionally overwrite figure.figsize, because if it's not specified, it's None, and that would overwrite the default in rcParams. That's why I have it pass in an empty dict when it's None. Anyway, I can push that one level up the call stack like you mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's unfortunate. Still probably best to handle it outside.