Matplotlib: WebAgg backend does not show any digits

I am using Python 2.7.6 32-bit with Matplotlib 1.3.1.
When I use the default backend, as in this example, the image is displayed:

import matplotlib.pyplot as plt plt.plot(range(10)) plt.show() 


When I try to use WebAgg, the MPL page loads automatically, but without any digits:

 import matplotlib matplotlib.use('webagg') import matplotlib.pyplot as plt plt.plot(range(10)) plt.show() 


I tested this code on Windows and Ubuntu using Firefox, Chrome and IE, without any success ...
Can someone help please? Thanks in advance!

+7
python browser matplotlib plot
source share
3 answers

After much searching and testing, I ended up using pip to uninstall Matplotlib, and then reinstalled it (be sure to use the --upgrade command):

 pip uninstall matplotlib pip install matplotlib --upgrade 

And it worked! Now I see WebAgg graphics in a browser window! Maybe I did not install Matplotlib correctly ...

Thanks for the suggestions!

+1
source share

Update to the latest development version of Matplotlib-1.4.x. Install in virtualenv using

 $ pip install -e git@github.com :matplotlib/matplotlib.git 

Then the OP commands work on all platforms. There is also a new built-in webagg example in the main matplotlib branch on GitHub , which works on all my systems (Windows-7x64, Ubuntu-14.14 and Xubuntu-14.14).

Using the OP commands with Matplotlib-1.3.1, I get mixed results depending on the platform used. On one machine (Ubuntu-14.14), I was able to show the shape if I used sudo to execute OP commands:

 $ sudo python >>> import matplotlib >>> matplotlib.use('webagg') >>> import matplotlib.pyplot as plt >>> plt.plot(range(10)) >>> plt.show() 

This works both in virtualenv and in the Ubuntu matplotlib distribution.

While on the VMWare Player virtual machine (Xubuntu-14.14, hosted on Windows-7x64), I was able to show the drawing using OP commands without sudo . On the third (Windows-7x64) machine, I still canโ€™t get the number using the OP commands with or without administrator privileges. I also changed matplotlib.rcParams['webagg.port'] to 8080 and 8000, but that also did not work.

In Ubuntu-14.14 using matplotlib installed from the distribution repository, you will see the following trace:

 File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_webagg.py", line 381, in get 'matplotlib.png'), 'rb') as fd: IOError: [Errno 2] No such file or directory: '/usr/lib/pymodules/python2.7/matplotlib/mpl-data/images/matplotlib.png' 

This has nothing to do with why the image does not appear; this error only appears on Linux machines where the mpl-data folder is not located where matplotlib.backends.backend_webagg expects it to be, but is actually located in /usr/share/matplotlib/ . In particular, backend_webagg looking for the backend_webagg file, which it uses as the icon for the web browser tab, and in fact Tornado will still serve the page, even if it does not find this file, although, unfortunately, it still calls this a mistake.

If you use virtualenv, you will not see favicon error.

Using Matplotlib-1.3.1 without sudo on Ubuntu-14.14 and on a Windows-7x64 machine, I get the same โ€œFigure 1โ€ link that @allisonmuller received in the comment above.

+1
source share

Just adding Mark Mikowski to the answer, I found that if you add a symbolic link as follows

cd / usr / lib / pymodules / python2.7 / matplotlib /

ln -s / usr / share / matplotlib / mpl-data mpl-data p>

the problem seems to be fixed.

0
source share

All Articles