Skip to content

Commit 2b18113

Browse files
all in one change
1 parent 2b16e2e commit 2b18113

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

pandas/plotting/_core.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,21 @@ def _setup_subplots(self):
308308

309309
axes = _flatten(axes)
310310

311-
if self.logx or self.loglog:
311+
valid_log = [False, True, 'sym', None]
312+
313+
for i in (self.logx, self.logy, self.loglog):
314+
if i not in valid_log:
315+
raise ValueError("Valid inputs are boolean, None and 'sym'.")
316+
317+
if self.logx is True or self.loglog is True:
312318
[a.set_xscale('log') for a in axes]
313-
if self.logy or self.loglog:
319+
elif self.logx == 'sym' or self.loglog == 'sym':
320+
[a.set_xscale('symlog') for a in axes]
321+
322+
if self.logy is True or self.loglog is True:
314323
[a.set_yscale('log') for a in axes]
324+
elif self.logy == 'sym' or self.loglog == 'sym':
325+
[a.set_yscale('symlog') for a in axes]
315326

316327
self.fig = fig
317328
self.axes = axes

pandas/tests/plotting/test_frame.py

+18
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,32 @@ def test_plot_xy(self):
231231
@pytest.mark.slow
232232
def test_logscales(self):
233233
df = DataFrame({'a': np.arange(100)}, index=np.arange(100))
234+
234235
ax = df.plot(logy=True)
235236
self._check_ax_scales(ax, yaxis='log')
237+
assert ax.get_yscale() == 'log'
238+
239+
ax = df.plot(logy='sym')
240+
self._check_ax_scales(ax, yaxis='symlog')
241+
assert ax.get_yscale() == 'symlog'
236242

237243
ax = df.plot(logx=True)
238244
self._check_ax_scales(ax, xaxis='log')
245+
assert ax.get_xscale() == 'log'
246+
247+
ax = df.plot(logx='sym')
248+
self._check_ax_scales(ax, xaxis='symlog')
249+
assert ax.get_xscale() == 'symlog'
239250

240251
ax = df.plot(loglog=True)
241252
self._check_ax_scales(ax, xaxis='log', yaxis='log')
253+
assert ax.get_xscale() == 'log'
254+
assert ax.get_yscale() == 'log'
255+
256+
ax = df.plot(loglog='sym')
257+
self._check_ax_scales(ax, xaxis='symlog', yaxis='symlog')
258+
assert ax.get_xscale() == 'symlog'
259+
assert ax.get_yscale() == 'symlog'
242260

243261
@pytest.mark.slow
244262
def test_xcompat(self):

0 commit comments

Comments
 (0)