Skip to content

Commit a82dd1d

Browse files
committed
Merge pull request #7394 from sinhrks/figsize
BUG: grouped hist and scatter use old figsize default
2 parents 0147b51 + 65a1246 commit a82dd1d

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

doc/source/v0.14.1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Bug Fixes
177177
- Bug in ``value_counts`` where ``NaT`` did not qualify as missing (``NaN``) (:issue:`7423`)
178178
- Bug in ``to_timedelta`` that accepted invalid units and misinterpreted 'm/h' (:issue:`7611`, :issue: `6423`)
179179

180+
- Bug in grouped ``hist`` and ``scatter`` plots use old ``figsize`` default (:issue:`7394`)
180181

181182
- Bug in ``Panel.apply`` with a multi-index as an axis (:issue:`7469`)
182183

pandas/tests/test_graphics.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,16 @@ def test_hist_layout_with_by(self):
603603
df = self.hist_df
604604

605605
axes = _check_plot_works(df.height.hist, by=df.gender, layout=(2, 1))
606-
self._check_axes_shape(axes, axes_num=2, layout=(2, 1), figsize=(10, 5))
606+
self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
607607

608608
axes = _check_plot_works(df.height.hist, by=df.category, layout=(4, 1))
609-
self._check_axes_shape(axes, axes_num=4, layout=(4, 1), figsize=(10, 5))
609+
self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
610610

611611
axes = _check_plot_works(df.height.hist, by=df.classroom, layout=(2, 2))
612-
self._check_axes_shape(axes, axes_num=3, layout=(2, 2), figsize=(10, 5))
612+
self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
613613

614-
axes = _check_plot_works(df.height.hist, by=df.category, layout=(4, 2))
615-
self._check_axes_shape(axes, axes_num=4, layout=(4, 2), figsize=(10, 5))
614+
axes = _check_plot_works(df.height.hist, by=df.category, layout=(4, 2), figsize=(12, 7))
615+
self._check_axes_shape(axes, axes_num=4, layout=(4, 2), figsize=(12, 7))
616616

617617
@slow
618618
def test_hist_no_overlap(self):
@@ -2255,11 +2255,11 @@ def test_grouped_hist(self):
22552255
df = DataFrame(randn(500, 2), columns=['A', 'B'])
22562256
df['C'] = np.random.randint(0, 4, 500)
22572257
axes = plotting.grouped_hist(df.A, by=df.C)
2258-
self._check_axes_shape(axes, axes_num=4, layout=(2, 2), figsize=(10, 5))
2258+
self._check_axes_shape(axes, axes_num=4, layout=(2, 2))
22592259

22602260
tm.close()
22612261
axes = df.hist(by=df.C)
2262-
self._check_axes_shape(axes, axes_num=4, layout=(2, 2), figsize=(10, 5))
2262+
self._check_axes_shape(axes, axes_num=4, layout=(2, 2))
22632263

22642264
tm.close()
22652265
# make sure kwargs to hist are handled
@@ -2281,6 +2281,9 @@ def test_grouped_hist(self):
22812281
with tm.assertRaises(AttributeError):
22822282
plotting.grouped_hist(df.A, by=df.C, foo='bar')
22832283

2284+
with tm.assert_produces_warning(FutureWarning):
2285+
df.hist(by='C', figsize='default')
2286+
22842287
@slow
22852288
def test_grouped_box_return_type(self):
22862289
df = self.hist_df
@@ -2374,29 +2377,28 @@ def test_grouped_hist_layout(self):
23742377
layout=(1, 3))
23752378

23762379
axes = _check_plot_works(df.hist, column='height', by=df.gender, layout=(2, 1))
2377-
self._check_axes_shape(axes, axes_num=2, layout=(2, 1), figsize=(10, 5))
2380+
self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
23782381

23792382
axes = _check_plot_works(df.hist, column='height', by=df.category, layout=(4, 1))
2380-
self._check_axes_shape(axes, axes_num=4, layout=(4, 1), figsize=(10, 5))
2383+
self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
23812384

23822385
axes = _check_plot_works(df.hist, column='height', by=df.category,
23832386
layout=(4, 2), figsize=(12, 8))
2384-
23852387
self._check_axes_shape(axes, axes_num=4, layout=(4, 2), figsize=(12, 8))
23862388

23872389
# GH 6769
23882390
axes = _check_plot_works(df.hist, column='height', by='classroom', layout=(2, 2))
2389-
self._check_axes_shape(axes, axes_num=3, layout=(2, 2), figsize=(10, 5))
2391+
self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
23902392

23912393
# without column
23922394
axes = _check_plot_works(df.hist, by='classroom')
2393-
self._check_axes_shape(axes, axes_num=3, layout=(2, 2), figsize=(10, 5))
2395+
self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
23942396

23952397
axes = _check_plot_works(df.hist, by='gender', layout=(3, 5))
2396-
self._check_axes_shape(axes, axes_num=2, layout=(3, 5), figsize=(10, 5))
2398+
self._check_axes_shape(axes, axes_num=2, layout=(3, 5))
23972399

23982400
axes = _check_plot_works(df.hist, column=['height', 'weight', 'category'])
2399-
self._check_axes_shape(axes, axes_num=3, layout=(2, 2), figsize=(10, 5))
2401+
self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
24002402

24012403
@slow
24022404
def test_axis_share_x(self):

pandas/tools/plotting.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,20 +2734,18 @@ def _grouped_plot(plotf, data, column=None, by=None, numeric_only=True,
27342734
rot=0, ax=None, **kwargs):
27352735
from pandas import DataFrame
27362736

2737-
# allow to specify mpl default with 'default'
2738-
if figsize is None or figsize == 'default':
2739-
figsize = (10, 5) # our default
2737+
if figsize == 'default':
2738+
# allowed to specify mpl default with 'default'
2739+
warnings.warn("figsize='default' is deprecated. Specify figure"
2740+
"size by tuple instead", FutureWarning)
2741+
figsize = None
27402742

27412743
grouped = data.groupby(by)
27422744
if column is not None:
27432745
grouped = grouped[column]
27442746

27452747
naxes = len(grouped)
27462748
nrows, ncols = _get_layout(naxes, layout=layout)
2747-
if figsize is None:
2748-
# our favorite default beating matplotlib's idea of the
2749-
# default size
2750-
figsize = (10, 5)
27512749
fig, axes = _subplots(nrows=nrows, ncols=ncols, naxes=naxes,
27522750
figsize=figsize, sharex=sharex, sharey=sharey, ax=ax)
27532751

0 commit comments

Comments
 (0)