[Pythonmac-SIG] matplotlib

Robin robince at gmail.com
Sun Nov 1 17:04:37 CET 2009


On Sun, Nov 1, 2009 at 3:50 PM, Charles Hartman
<charles.hartman at conncoll.edu> wrote:
>
> So now I've installed it, and I can do 'import matplotlib' in Python.  But
> when I try to use it (on an example from the new "Natural Language
> Processing with Python"), here's what I get:
>
>>>> import matplotlib
>>>> text4.dispersion_plot(["citizens", "democracy", "freedom", "duties",
>>>> "America"])
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File
> "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/nltk/text.py",
> line 452, in dispersion_plot
>    dispersion_plot(self, words)
>  File
> "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/nltk/draw/dispersion.py",
> line 25, in dispersion_plot
>    raise ValueError('The plot function requires the matplotlib package.'
> ValueError: The plot function requires the matplotlib package.See
> http://matplotlib.sourceforge.net/
>>>>

dispersion.py is trying to import pylab. So you could try "import
pylab" in Python and see what error you get.
Also you could try and plot something:
from pylab import plot
x = range(1)
plot(x,x)

But I do think either the NLTK or matplotlib mailing lists would be
more appropriate for you to get help with this.

Also I'd recommend using ipython if you want to work with matplotlib
plots interactively. It's an interpreter that has much nicer behaviour
for interactive work.

Cheers

Robin


More information about the Pythonmac-SIG mailing list