Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib: WebAgg backend doesn't show any figures

I'm using Python 2.7.6 32-bit with Matplotlib 1.3.1.
When I use the default backend, like in this example, the figure is shown:

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 figures:

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 somebody help, please? Thanks in advance!

like image 680
alissonmuller Avatar asked Feb 27 '14 21:02

alissonmuller


People also ask

Why is my plot empty in Python?

Because, when plt. show is executed, it displays figure on the screen and closes the figure. This is why you get an empty plot when you save it after plt.

What is matplotlib backend AGG?

The last, Agg, is a non-interactive backend that can only write to files. It is used on Linux, if Matplotlib cannot connect to either an X display or a Wayland display.


1 Answers

After a lot of searching and testing, I ended up using pip to uninstall Matplotlib, then reinstall it (using the --upgrade command, just to be sure):

pip uninstall matplotlib
pip install matplotlib --upgrade

And it worked! Now I can see the WebAgg plots on the browser window! Maybe I wasn't installing Matplotlib properly...

Thanks for the suggestions!

like image 81
alissonmuller Avatar answered Oct 15 '22 09:10

alissonmuller