X Tutup
Skip to content

Catch invalid interactive switch to log scale.#6983

Merged
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:dont-crash-on-interactive-invalid-log
Aug 27, 2016
Merged

Catch invalid interactive switch to log scale.#6983
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:dont-crash-on-interactive-invalid-log

Conversation

@anntzer
Copy link
Copy Markdown
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
Copy Markdown
Member

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

@anntzer
Copy link
Copy Markdown
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
Copy Markdown
Member

Yes 👍

@LindyBalboa
Copy link
Copy Markdown
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
Copy Markdown
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

X Tutup