Matplotlib plots display as blank in interactive mode with no error messages - (one) Solution

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Matplotlib plots display as blank in interactive mode with no error messages - (one) Solution

FilipPersson
I spent several hours googling and trying myself to change my code to fix
this. No luck in googling and the fact that there was a kind of doing brain
surgery on Matplotlib by uninstall, re-install and update and change backend
library for a similar but not quite the same problem made me think that I
should post the solution somewhere since it was almost impossible to spot.

If you get plots like this:
<http://matplotlib.1069221.n5.nabble.com/file/t5236/Blank_plot.png>
Which, as you see gives no error output - not even when clicking on the
graph. Actually, nothing at all happens when clicking on the graph.
Interactivity is lost.

It could be a LaTeX problem causing it!
The reason for the blank plot was that I had used a LaTeX escape character
for the value 0 when creating nice labels for the x axis. Apparently, using
'$\0$' to write the number zero in LaTeX makes the plots blank and kills the
interactivity. Restarting the kernel did no good.
If I instead write '$0$' as a label, everything works fine again.

My environment is Mac OSX 10.13.6, Matplotlib 3.0.2, Python 3.7.1, running
in Jupyter (notebook server version 5.7.4, IPython 7.2.0) in Safari Version
12.0 (13606.2.11).

If you want to see my code, please request it and then I will post it.



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Matplotlib plots display as blank in interactive mode with no error messages - (one) Solution

tcaswell
This is possible related to https://github.com/matplotlib/matplotlib/issues/13988 .  What backend are you using?

Tom

On Fri, May 17, 2019 at 5:19 AM FilipPersson <[hidden email]> wrote:
I spent several hours googling and trying myself to change my code to fix
this. No luck in googling and the fact that there was a kind of doing brain
surgery on Matplotlib by uninstall, re-install and update and change backend
library for a similar but not quite the same problem made me think that I
should post the solution somewhere since it was almost impossible to spot.

If you get plots like this:
<http://matplotlib.1069221.n5.nabble.com/file/t5236/Blank_plot.png>
Which, as you see gives no error output - not even when clicking on the
graph. Actually, nothing at all happens when clicking on the graph.
Interactivity is lost.

It could be a LaTeX problem causing it!
The reason for the blank plot was that I had used a LaTeX escape character
for the value 0 when creating nice labels for the x axis. Apparently, using
'$\0$' to write the number zero in LaTeX makes the plots blank and kills the
interactivity. Restarting the kernel did no good.
If I instead write '$0$' as a label, everything works fine again.

My environment is Mac OSX 10.13.6, Matplotlib 3.0.2, Python 3.7.1, running
in Jupyter (notebook server version 5.7.4, IPython 7.2.0) in Safari Version
12.0 (13606.2.11).

If you want to see my code, please request it and then I will post it.



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Matplotlib plots display as blank in interactive mode with no error messages - (one) Solution

FilipPersson
Hi Tom,
I'm not sure if it's related. I'm using nbAgg. It acme automatically when I
installed and I haven't changed it. Their plots go black. Not all my plots
go crazy when I do the escape character error, only the interactive ones
when re-running.



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Matplotlib plots display as blank in interactive mode with no error messages - (one) Solution

tcaswell
Indeed, sorry for the misdirection.

If you look in your terminal do you see a bunch of tracebacks?  

The problem is that Python read \0 in a string literal as an escaped 0 byte (aka \x00) which fails to parse with with mathtex and latex.  If you make a raw string (r"$\0$") python won't interpret the escape character, but both mathtex and latex still fail as \0 is not a valid command it latex.  These exceptions are being raised as part of the draw process which cause it to fail which makes it look like interactivity is lost because the updated image is not shipped to the browser.

We should sort out a better way to surface those exceptions, the problem is that they happen asynchronously so it is not clear where they should be raised...

Tom  

On Sun, May 19, 2019 at 3:51 AM FilipPersson <[hidden email]> wrote:
Hi Tom,
I'm not sure if it's related. I'm using nbAgg. It acme automatically when I
installed and I haven't changed it. Their plots go black. Not all my plots
go crazy when I do the escape character error, only the interactive ones
when re-running.



--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users