-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
ENH: Expose symlog scaling in plotting API #24968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
88705a5
7bf16e4
446bcc0
238d1f4
8941bdf
f8b124a
549dd4d
0ea6653
8b9ede1
3a265e9
a3e71c9
9c205f5
d0e5c41
5170000
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,10 +308,21 @@ def _setup_subplots(self): | |
|
||
axes = _flatten(axes) | ||
|
||
if self.logx or self.loglog: | ||
valid_log = {False, True, 'sym', None} | ||
input_log = {self.logx, self.logy, self.loglog} | ||
if input_log - valid_log: | ||
raise ValueError(f"Valid inputs are boolean, None and 'sym'" | ||
|
||
f", {i} is given.") | ||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,14 +231,42 @@ 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.parametrize("wrong_input", ["sm", "symlog"]) | ||
@pytest.mark.parametrize("input_param", ["logx", "logy", "loglog"]) | ||
def test_invalid_logscale(self, wrong_input, input_param): | ||
# GH: 24867 | ||
df = DataFrame({'a': np.arange(100)}, index=np.arange(100)) | ||
|
||
msg = "Valid inputs are boolean, None and 'sym'" | ||
|
||
with pytest.raises(ValueError, match=msg): | ||
df.plot(**{input_param: wrong_input}) | ||
|
||
@pytest.mark.slow | ||
def test_xcompat(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.