Skip to content

Commit cf55a91

Browse files
author
y-p
committed
BUG: work around mpl 1.2.1 regression, ax.axhline(0) with log=true GH3298
1 parent 7358b5b commit cf55a91

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pandas/tests/test_graphics.py

+3
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ def test_bar_center(self):
406406
ax.patches[0].get_x() + ax.patches[0].get_width())
407407
@slow
408408
def test_bar_log(self):
409+
# GH3254, GH3298 matplotlib/matplotlib#1882, #1892
410+
# regressions in 1.2.1
411+
409412
df = DataFrame({'A': [3] * 5, 'B': range(5)}, index=range(5))
410413
ax = df.plot(kind='bar', grid=True,log=True)
411414
self.assertEqual(ax.yaxis.get_ticklocs()[0],1.0)

pandas/tools/plotting.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@ def __init__(self, data, **kwargs):
13251325
else:
13261326
self.tickoffset = 0.375
13271327
self.bar_width = 0.5
1328+
self.log = kwargs.pop('log',False)
13281329
MPLPlot.__init__(self, data, **kwargs)
13291330

13301331
def _args_adjust(self):
@@ -1335,9 +1336,9 @@ def _args_adjust(self):
13351336
def bar_f(self):
13361337
if self.kind == 'bar':
13371338
def f(ax, x, y, w, start=None, **kwds):
1338-
return ax.bar(x, y, w, bottom=start, **kwds)
1339+
return ax.bar(x, y, w, bottom=start,log=self.log, **kwds)
13391340
elif self.kind == 'barh':
1340-
def f(ax, x, y, w, start=None, **kwds):
1341+
def f(ax, x, y, w, start=None, log=self.log, **kwds):
13411342
return ax.barh(x, y, w, left=start, **kwds)
13421343
else:
13431344
raise NotImplementedError
@@ -1411,7 +1412,8 @@ def _post_plot_logic(self):
14111412
ax.set_xticks(self.ax_pos + self.tickoffset)
14121413
ax.set_xticklabels(str_index, rotation=self.rot,
14131414
fontsize=self.fontsize)
1414-
ax.axhline(0, color='k', linestyle='--')
1415+
if not self.log: # GH3254+
1416+
ax.axhline(0, color='k', linestyle='--')
14151417
if name is not None:
14161418
ax.set_xlabel(name)
14171419
else:

0 commit comments

Comments
 (0)