Skip to content

Commit 186a09c

Browse files
committed
fixing style issues
1 parent db6cf67 commit 186a09c

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

pandas/plotting/_core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,12 @@ def _make_plot(self):
870870
scatter = ax.scatter(data[x].values, data[y].values, c=c_values,
871871
label=label, cmap=cmap, **self.kwds)
872872
if cb:
873+
# The following attribute determines which axes belong to
874+
# colorbars. When sharex = True, this allows `_handle_shared_axes`
875+
# to skip them. Otherwise colobars will cause x-axis label and
876+
# tick labels to disappear.
873877
ax._pandas_colorbar_axes = True
878+
874879
img = ax.collections[0]
875880
kws = dict(ax=ax)
876881
if self.mpl_ge_1_3_1():
@@ -917,7 +922,12 @@ def _make_plot(self):
917922
ax.hexbin(data[x].values, data[y].values, C=c_values, cmap=cmap,
918923
**self.kwds)
919924
if cb:
925+
# The following attribute determines which axes belong to
926+
# colorbars. When sharex = True, this allows `_handle_shared_axes`
927+
# to skip them. Otherwise colobars will cause x-axis label and
928+
# tick labels to disappear.
920929
ax._pandas_colorbar_axes = True
930+
921931
img = ax.collections[0]
922932
self.fig.colorbar(img, ax=ax)
923933

pandas/plotting/_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ def _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey):
311311
# only the last row of subplots should get x labels -> all
312312
# other off layout handles the case that the subplot is
313313
# the last in the column, because below is no subplot/gap.
314-
if not layout[ax.rowNum + 1, ax.colNum] or \
315-
getattr(ax, '_pandas_colorbar_axes', False):
314+
if (not layout[ax.rowNum + 1, ax.colNum] or
315+
getattr(ax, '_pandas_colorbar_axes', False)):
316316
continue
317317
if sharex or len(ax.get_shared_x_axes()
318318
.get_siblings(ax)) > 1:

pandas/tests/plotting/test_frame.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,39 +1033,39 @@ def test_plot_scatter(self):
10331033
@pytest.mark.slow
10341034
def test_if_scatterplot_colorbar_affects_xaxis_visibility(self):
10351035
random_array = np.random.random((1000, 3))
1036-
df = pd.DataFrame(random_array,columns=['A label', 'B label', 'C label'])
1036+
df = pd.DataFrame(random_array,
1037+
columns=['A label', 'B label', 'C label'])
10371038

10381039
ax1 = df.plot.scatter(x='A label', y='B label')
10391040
ax2 = df.plot.scatter(x='A label', y='B label', c='C label')
10401041

1041-
assert all([vis[0].get_visible() == vis[1].get_visible() for vis in
1042-
zip(ax1.xaxis.get_minorticklabels(),
1043-
ax2.xaxis.get_minorticklabels())]), \
1044-
'minor x-axis tick labels visibility ' \
1045-
'changes when colorbar included'
1046-
assert all([vis[0].get_visible() == vis[1].get_visible() for vis in
1047-
zip(ax1.xaxis.get_majorticklabels(),
1048-
ax2.xaxis.get_majorticklabels())]), \
1049-
'major x-axis tick labels visibility ' \
1050-
'changes when colorbar included'
1051-
assert ax1.xaxis.get_label().get_visible() == \
1052-
ax2.xaxis.get_label().get_visible(), \
1053-
'x-axis label visibility changes when colorbar included'
1042+
vis1 = [vis.get_visible() for vis in
1043+
ax1.xaxis.get_minorticklabels()]
1044+
vis2 = [vis.get_visible() for vis in
1045+
ax2.xaxis.get_minorticklabels()]
1046+
assert vis1 == vis2
1047+
1048+
vis1 = [vis.get_visible() for vis in
1049+
ax1.xaxis.get_majorticklabels()]
1050+
vis2 = [vis.get_visible() for vis in
1051+
ax2.xaxis.get_majorticklabels()]
1052+
assert vis1 == vis2
1053+
1054+
assert (ax1.xaxis.get_label().get_visible() ==
1055+
ax2.xaxis.get_label().get_visible())
10541056

10551057
@pytest.mark.slow
10561058
def test_if_hexbin_xaxis_label_is_visible(self):
10571059
random_array = np.random.random((1000, 3))
1058-
df = pd.DataFrame(random_array,columns=['A label', 'B label', 'C label'])
1060+
df = pd.DataFrame(random_array,
1061+
columns=['A label', 'B label', 'C label'])
10591062

10601063
ax = df.plot.hexbin('A label', 'B label', gridsize=12)
10611064
assert all([vis.get_visible() for vis in
1062-
ax.xaxis.get_minorticklabels()]), \
1063-
'minor x-axis tick labels are not visible'
1065+
ax.xaxis.get_minorticklabels()])
10641066
assert all([vis.get_visible() for vis in
1065-
ax.xaxis.get_majorticklabels()]), \
1066-
'major x-axis tick labels are not visible'
1067-
assert ax.xaxis.get_label().get_visible(), \
1068-
'x-axis label is not visible'
1067+
ax.xaxis.get_majorticklabels()])
1068+
assert ax.xaxis.get_label().get_visible()
10691069

10701070
@pytest.mark.slow
10711071
def test_plot_scatter_with_categorical_data(self):

0 commit comments

Comments
 (0)