Skip to content

Commit 631e0ba

Browse files
committed
TST: windows test fixes for 2.6 / older mpl
1 parent 62529cc commit 631e0ba

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

pandas/tests/test_graphics.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ def setUp(self):
910910
mpl.rcdefaults()
911911

912912
self.mpl_le_1_2_1 = str(mpl.__version__) <= LooseVersion('1.2.1')
913+
self.mpl_ge_1_3_1 = str(mpl.__version__) >= LooseVersion('1.3.1')
913914

914915
self.tdf = tm.makeTimeDataFrame()
915916
self.hexbin_df = DataFrame({"A": np.random.uniform(size=20),
@@ -1531,9 +1532,12 @@ def test_plot_scatter_with_c(self):
15311532
for ax in axes:
15321533
# default to RdBu
15331534
self.assertEqual(ax.collections[0].cmap.name, 'RdBu')
1534-
# n.b. there appears to be no public method to get the colorbar
1535-
# label
1536-
self.assertEqual(ax.collections[0].colorbar._label, 'z')
1535+
1536+
if self.mpl_ge_1_3_1:
1537+
1538+
# n.b. there appears to be no public method to get the colorbar
1539+
# label
1540+
self.assertEqual(ax.collections[0].colorbar._label, 'z')
15371541

15381542
cm = 'cubehelix'
15391543
ax = df.plot(kind='scatter', x='x', y='y', c='z', colormap=cm)
@@ -1893,7 +1897,7 @@ def test_boxplot_axis_limits(self):
18931897

18941898
def _check_ax_limits(col, ax):
18951899
y_min, y_max = ax.get_ylim()
1896-
self.assertLessEqual(y_min, col.min())
1900+
self.assertTrue(y_min <= col.min())
18971901
self.assertGreaterEqual(y_max, col.max())
18981902

18991903
df = self.hist_df.copy()

pandas/tools/plotting.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,9 @@ def nseries(self):
13921392
return 1
13931393

13941394
def _make_plot(self):
1395+
import matplotlib as mpl
1396+
mpl_ge_1_3_1 = str(mpl.__version__) >= LooseVersion('1.3.1')
1397+
13951398
import matplotlib.pyplot as plt
13961399

13971400
x, y, c, data = self.x, self.y, self.c, self.data
@@ -1419,8 +1422,10 @@ def _make_plot(self):
14191422
label=label, cmap=cmap, **self.kwds)
14201423
if cb:
14211424
img = ax.collections[0]
1422-
cb_label = c if c in self.data.columns else ''
1423-
self.fig.colorbar(img, ax=ax, label=cb_label)
1425+
kws = dict(ax=ax)
1426+
if mpl_ge_1_3_1:
1427+
kws['label'] = c if c in self.data.columns else ''
1428+
self.fig.colorbar(img, **kws)
14241429

14251430
self._add_legend_handle(scatter, label)
14261431

0 commit comments

Comments
 (0)