I am using python 3 in Ubuntu 13.04.
This simple example runs without errors, but it doesn't display any plot:
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = [4,3,2,1]
plt.plot(x, y)
plt.show()
I have tried to change the backend from Agg to TkAgg but I get the following error:
Traceback (most recent call last):
File "test2.py", line 1, in
import matplotlib.pyplot as plt
File "/usr/local/lib/python3.2/dist-packages/matplotlib/pyplot.py", line> 98, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.2/dist-packages/matplotlib/backends/init.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.2/dist-packages/matplotlib/backends/backend_tkagg.py",line 11, in
import matplotlib.backends.tkagg as tkagg
File "/usr/local/lib/python3.2/dist-packages/matplotlib/backends/tkagg.py",line 2, in
from matplotlib.backends import _tkagg
ImportError: cannot import name _tkagg
Does anyone have any idea how to solve this?
EDIT:
I have found the answer here. In case someone has the same problem, the solution is to install the tk-dev package on ubuntu, and then reinstall matplotlib. In my case:
sudo apt-get install tk-dev
sudo pip3 uninstall matplotlib
sudo pip3 install matplotlib