Skip to content

Commit e2abff6

Browse files
committed
removed colorbars from _handle_shared_axes when called by scatterplot and hexbin
1 parent 17c1fad commit e2abff6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas/plotting/_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,12 +869,16 @@ def _make_plot(self):
869869
label = None
870870
scatter = ax.scatter(data[x].values, data[y].values, c=c_values,
871871
label=label, cmap=cmap, **self.kwds)
872+
872873
if cb:
874+
ax._pandas_colorbar_axes = True
873875
img = ax.collections[0]
874876
kws = dict(ax=ax)
875877
if self.mpl_ge_1_3_1():
876878
kws['label'] = c if c_is_column else ''
877879
self.fig.colorbar(img, **kws)
880+
881+
878882

879883
if label is not None:
880884
self._add_legend_handle(scatter, label)
@@ -902,6 +906,7 @@ def __init__(self, data, x, y, C=None, **kwargs):
902906
def _make_plot(self):
903907
x, y, data, C = self.x, self.y, self.data, self.C
904908
ax = self.axes[0]
909+
905910
# pandas uses colormap, matplotlib uses cmap.
906911
cmap = self.colormap or 'BuGn'
907912
cmap = self.plt.cm.get_cmap(cmap)
@@ -915,6 +920,7 @@ def _make_plot(self):
915920
ax.hexbin(data[x].values, data[y].values, C=c_values, cmap=cmap,
916921
**self.kwds)
917922
if cb:
923+
ax._pandas_colorbar_axes = True
918924
img = ax.collections[0]
919925
self.fig.colorbar(img, ax=ax)
920926

pandas/plotting/_tools.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,18 @@ def _remove_labels_from_axis(axis):
298298

299299
def _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey):
300300
if nplots > 1:
301-
302301
if nrows > 1:
303302
try:
304303
# first find out the ax layout,
305304
# so that we can correctly handle 'gaps"
306305
layout = np.zeros((nrows + 1, ncols + 1), dtype=np.bool)
307306
for ax in axarr:
308307
layout[ax.rowNum, ax.colNum] = ax.get_visible()
309-
310308
for ax in axarr:
311309
# only the last row of subplots should get x labels -> all
312310
# other off layout handles the case that the subplot is
313-
# the last in the column, because below is no subplot/gap.
314-
if not layout[ax.rowNum + 1, ax.colNum]:
311+
# the last in the column, because below is no subplot/gap.
312+
if not layout[ax.rowNum + 1, ax.colNum] or getattr(ax, '_pandas_colorbar_axes', False):
315313
continue
316314
if sharex or len(ax.get_shared_x_axes()
317315
.get_siblings(ax)) > 1:

0 commit comments

Comments
 (0)