Skip to content

Commit 9f9e3da

Browse files
add sym option for logx logy loglog and tests
1 parent 2626215 commit 9f9e3da

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pandas/plotting/_core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def _kind(self):
8282
_default_rot = 0
8383
orientation = None
8484
_pop_attributes = ['label', 'style', 'logy', 'logx', 'loglog',
85-
'mark_right', 'stacked']
85+
'mark_right', 'stacked', 'sym']
8686
_attr_defaults = {'logy': False, 'logx': False, 'loglog': False,
87-
'mark_right': True, 'stacked': False}
87+
'mark_right': True, 'stacked': False, 'sym': False}
8888

8989
def __init__(self, data, kind=None, by=None, subplots=False, sharex=None,
9090
sharey=False, use_index=True,
@@ -309,9 +309,15 @@ def _setup_subplots(self):
309309
axes = _flatten(axes)
310310

311311
if self.logx or self.loglog:
312-
[a.set_xscale('log') for a in axes]
312+
if self.sym:
313+
[a.set_xscale('symlog') for a in axes]
314+
else:
315+
[a.set_xscale('log') for a in axes]
313316
if self.logy or self.loglog:
314-
[a.set_yscale('log') for a in axes]
317+
if self.sym:
318+
[a.set_yscale('symlog') for a in axes]
319+
else:
320+
[a.set_yscale('log') for a in axes]
315321

316322
self.fig = fig
317323
self.axes = axes

pandas/tests/plotting/test_frame.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,18 @@ def test_logscales(self):
233233
df = DataFrame({'a': np.arange(100)}, index=np.arange(100))
234234
ax = df.plot(logy=True)
235235
self._check_ax_scales(ax, yaxis='log')
236+
ax = df.plot(logy=True, sym=True)
237+
self._check_ax_scales(ax, yaxis='symlog')
236238

237239
ax = df.plot(logx=True)
238240
self._check_ax_scales(ax, xaxis='log')
241+
ax = df.plot(logx=True, sym=True)
242+
self._check_ax_scales(ax, xaxis='symlog')
239243

240244
ax = df.plot(loglog=True)
241245
self._check_ax_scales(ax, xaxis='log', yaxis='log')
246+
ax = df.plot(loglog=True, sym=True)
247+
self._check_ax_scales(ax, xaxis='symlog', yaxis='symlog')
242248

243249
@pytest.mark.slow
244250
def test_xcompat(self):

0 commit comments

Comments
 (0)