Skip to content

Catch invalid interactive switch to log scale. #6983

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2578,7 +2578,11 @@ def _get_uniform_gridstate(ticks):
ax.set_yscale('linear')
ax.figure.canvas.draw_idle()
elif scale == 'linear':
ax.set_yscale('log')
try:
ax.set_yscale('log')
except ValueError as exc:
warnings.warn(str(exc))
ax.set_yscale('linear')
ax.figure.canvas.draw_idle()
# toggle scaling of x-axes between 'log and 'linear' (default key 'k')
elif event.key in toggle_xscale_keys:
Expand All @@ -2587,7 +2591,11 @@ def _get_uniform_gridstate(ticks):
ax.set_xscale('linear')
ax.figure.canvas.draw_idle()
elif scalex == 'linear':
ax.set_xscale('log')
try:
ax.set_xscale('log')
except ValueError:
warnings.warn(str(exc))
ax.set_xscale('linear')
ax.figure.canvas.draw_idle()

elif (event.key.isdigit() and event.key != '0') or event.key in all_keys:
Expand Down