Skip to content

Commit 7358b5b

Browse files
author
y-p
committed
BUG: work around mpl 1.2.1 regression, bar(log=True,bottom=None)) GH3254
1 parent 6e74f8a commit 7358b5b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pandas/tests/test_graphics.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,14 @@ def test_bar_center(self):
408408
def test_bar_log(self):
409409
df = DataFrame({'A': [3] * 5, 'B': range(5)}, index=range(5))
410410
ax = df.plot(kind='bar', grid=True,log=True)
411-
self.assertEqual(ax.yaxis.get_ticklocs()[0],0.1)
411+
self.assertEqual(ax.yaxis.get_ticklocs()[0],1.0)
412+
413+
p1 = Series([200,500]).plot(log=True,kind='bar')
414+
p2 = DataFrame([Series([200,300]),Series([300,500])]).plot(log=True,kind='bar',subplots=True)
415+
416+
(p1.yaxis.get_ticklocs() == np.array([ 0.625, 1.625]))
417+
(p2[0].yaxis.get_ticklocs() == np.array([ 100., 1000.])).all()
418+
(p2[1].yaxis.get_ticklocs() == np.array([ 100., 1000.])).all()
412419

413420
@slow
414421
def test_boxplot(self):

pandas/tools/plotting.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ def _get_colors(self):
13541354
return colors
13551355

13561356
def _make_plot(self):
1357+
import matplotlib as mpl
13571358
colors = self._get_colors()
13581359
rects = []
13591360
labels = []
@@ -1371,10 +1372,15 @@ def _make_plot(self):
13711372
kwds = self.kwds.copy()
13721373
kwds['color'] = colors[i % len(colors)]
13731374

1375+
# default, GH3254
1376+
# I tried, I really did.
1377+
start = 0 if mpl.__version__ == "1.2.1" else None
13741378
if self.subplots:
13751379
ax = self._get_ax(i) # self.axes[i]
1376-
rect = bar_f(ax, self.ax_pos, y,
1377-
self.bar_width, **kwds)
1380+
1381+
rect = bar_f(ax, self.ax_pos, y, self.bar_width,
1382+
start = start,
1383+
**kwds)
13781384
ax.set_title(label)
13791385
elif self.stacked:
13801386
mask = y > 0
@@ -1385,6 +1391,7 @@ def _make_plot(self):
13851391
neg_prior = neg_prior + np.where(mask, 0, y)
13861392
else:
13871393
rect = bar_f(ax, self.ax_pos + i * 0.75 / K, y, 0.75 / K,
1394+
start = start,
13881395
label=label, **kwds)
13891396
rects.append(rect)
13901397
labels.append(label)

0 commit comments

Comments
 (0)