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

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 26, 2016

plt.plot([1, 2], [-1, -2]) and press l (switch y to log-scale).
Before, this would crash the Qt5 backend and cause an invalid internal
state in others, due to the complete lack of positive values. Now a
warning is printed and the command is cancelled.

See #6852.

`plt.plot([1, 2], [-1, -2])` and press `l` (switch y to log-scale).
Before, this would crash the Qt5 backend and cause an invalid internal
state in others, due to the complete lack of positive values.  Now a
warning is printed and the command is cancelled.
@jenshnielsen
Copy link
Member

Makes sense to me. How does the warning look. Should we change it to something more user friendly?

@anntzer
Copy link
Contributor Author

anntzer commented Aug 26, 2016

/home/antony/src/extern/matplotlib/lib/matplotlib/axes/_base.py:2276: RuntimeWarning: invalid value encountered in double_scalars
  delta = (x1t - x0t) * margin
/home/antony/src/extern/matplotlib/lib/matplotlib/backend_bases.py:2584: UserWarning: Data has no positive values, and therefore can not be log-scaled.
  warnings.warn(str(exc))

I think it's clear enough?

@jenshnielsen
Copy link
Member

Yes 👍

@LindyBalboa
Copy link
Contributor

Looks good. I wasn't aware of the warnings module. Good to know!

@tacaswell tacaswell merged commit f95169e into matplotlib:master Aug 27, 2016
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Aug 27, 2016
tacaswell added a commit that referenced this pull request Aug 27, 2016
…id-log

FIX: Catch invalid interactive switch to log scale.
Conflicts:
	lib/matplotlib/backend_bases.py
  	   did not backport draw -> draw_idle change
@tacaswell
Copy link
Member

backported to v2.x as ac01d85

@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.1 (next point release) Aug 27, 2016
@anntzer anntzer deleted the dont-crash-on-interactive-invalid-log branch September 12, 2016 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants