'Can not display plot with matplotlib under eclipse
I have a strange problem with matplotlib under Eclipse I've tested this code and this works fine in the command line:
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
But when I execute this code under Eclipse, there is nothing shown. I see that pydev understood all my imports and there is no error message.
Solution 1:[1]
using Ubuntu 12.04 and i have installed python3.3 This is what worked for me.
You need to have freetype. sudo apt-get install freetype*
You need to have freetype. sudo apt-get install python3.3-dev
You need to have g++. sudo apt-get install g++
You need to have libevent-dev sudo apt-get install libevent-dev
You need to have libpng-dev sudo apt-get install libpng-dev
You need to have libjpeg8-dev sudo apt-get install libjpeg8-dev
You need to have python3.3-tk sudo apt-get install python3.3-tk
You need to have tk-dev sudo apt-get install tk-dev
You need to have python-gtk2-dev sudo apt-get install python-gtk2-dev
Get the tar file from the website and untar it in the dist-packages /usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1. sudo python3.3 setup.py clean (this might be optional) sudo python3.3 setup.py install
NOTE: I had to change the matplotlibrc file in the dist-packages in the mpl-data directory. The backend line was changed from agg to TkAgg and interactive was set to True.
Solution 2:[2]
In my case, the Python Interpreters doesn't recognize matplotlib installing. Try to apply Python Interpreters again.
Window -> Preferences -> PyDev -> Interpreters -> Python Interpreters -> Apply -> Select python interpreters -> OK -> Apply and Close.
Hope it works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user3195916 |
| Solution 2 | DungNH |
