Skip to content

Commit 6e1e4aa

Browse files
author
TomAugspurger
committed
BUG: hidden ticklabels with sharex and secondary axes and existing subplots
1 parent def58c9 commit 6e1e4aa

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

doc/source/whatsnew/v0.16.0.txt

+5
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,8 @@ Bug Fixes
138138
- DataFrame now properly supports simultaneous ``copy`` and ``dtype`` arguments in constructor (:issue:`9099`)
139139
- Bug in read_csv when using skiprows on a file with CR line endings with the c engine. (:issue:`9079`)
140140
- isnull now detects NaT in PeriodIndex (:issue:`9129`)
141+
142+
143+
144+
- Bug in hiding ticklabels with subplots and shared axes when adding a
145+
- new plot to an existing grid of axes (:issue:`9158`)

pandas/tests/test_graphics.py

+13
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,19 @@ def test_subplots_ts_share_axes(self):
13681368
for ax in axes[[0, 1, 2], [2]].ravel():
13691369
self._check_visible(ax.get_yticklabels(), visible=False)
13701370

1371+
def test_subplots_sharex_axes_existing_axes(self):
1372+
# GH 9158
1373+
d = {'A': [1., 2., 3., 4.], 'B': [4., 3., 2., 1.], 'C': [5, 1, 3, 4]}
1374+
df = DataFrame(d, index=date_range('2014 10 11', '2014 10 14'))
1375+
1376+
axes = df[['A', 'B']].plot(subplots=True)
1377+
df['C'].plot(ax=axes[0], secondary_y=True)
1378+
1379+
self._check_visible(axes[0].get_xticklabels(), visible=False)
1380+
self._check_visible(axes[1].get_xticklabels(), visible=True)
1381+
for ax in axes.ravel():
1382+
self._check_visible(ax.get_yticklabels(), visible=True)
1383+
13711384
def test_negative_log(self):
13721385
df = - DataFrame(rand(6, 4),
13731386
index=list(string.ascii_letters[:6]),

pandas/tools/plotting.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,10 @@ def _adorn_subplots(self):
10251025
if len(self.axes) > 0:
10261026
all_axes = self._get_axes()
10271027
nrows, ncols = self._get_axes_layout()
1028-
_handle_shared_axes(all_axes, len(all_axes), len(all_axes), nrows, ncols, self.sharex, self.sharey)
1028+
_handle_shared_axes(axarr=all_axes, nplots=len(all_axes),
1029+
naxes=nrows * ncols, nrows=nrows,
1030+
ncols=ncols, sharex=self.sharex,
1031+
sharey=self.sharey)
10291032

10301033
for ax in to_adorn:
10311034
if self.yticks is not None:

0 commit comments

Comments
 (0)