Skip to content

Commit

Permalink
all in one change
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesdong1991 committed Jan 27, 2019
1 parent 2b16e2e commit 2b18113
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,21 @@ def _setup_subplots(self):

axes = _flatten(axes)

if self.logx or self.loglog:
valid_log = [False, True, 'sym', None]

for i in (self.logx, self.logy, self.loglog):
if i not in valid_log:
raise ValueError("Valid inputs are boolean, None and 'sym'.")

if self.logx is True or self.loglog is True:
[a.set_xscale('log') for a in axes]
if self.logy or self.loglog:
elif self.logx == 'sym' or self.loglog == 'sym':
[a.set_xscale('symlog') for a in axes]

if self.logy is True or self.loglog is True:
[a.set_yscale('log') for a in axes]
elif self.logy == 'sym' or self.loglog == 'sym':
[a.set_yscale('symlog') for a in axes]

self.fig = fig
self.axes = axes
Expand Down
18 changes: 18 additions & 0 deletions pandas/tests/plotting/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,32 @@ def test_plot_xy(self):
@pytest.mark.slow
def test_logscales(self):
df = DataFrame({'a': np.arange(100)}, index=np.arange(100))

ax = df.plot(logy=True)
self._check_ax_scales(ax, yaxis='log')
assert ax.get_yscale() == 'log'

ax = df.plot(logy='sym')
self._check_ax_scales(ax, yaxis='symlog')
assert ax.get_yscale() == 'symlog'

ax = df.plot(logx=True)
self._check_ax_scales(ax, xaxis='log')
assert ax.get_xscale() == 'log'

ax = df.plot(logx='sym')
self._check_ax_scales(ax, xaxis='symlog')
assert ax.get_xscale() == 'symlog'

ax = df.plot(loglog=True)
self._check_ax_scales(ax, xaxis='log', yaxis='log')
assert ax.get_xscale() == 'log'
assert ax.get_yscale() == 'log'

ax = df.plot(loglog='sym')
self._check_ax_scales(ax, xaxis='symlog', yaxis='symlog')
assert ax.get_xscale() == 'symlog'
assert ax.get_yscale() == 'symlog'

@pytest.mark.slow
def test_xcompat(self):
Expand Down

0 comments on commit 2b18113

Please sign in to comment.