nltk dispersion_plot() function not working. Has the line-style "|" been removed from matplotlib?

530 views Asked by At

I am trying to draw lexical dispersion plots using nltk dispersion_plot() function. My code is

from nltk.book import *
text4.dispersion_plot(["freedom","citizens"])

The resulting plot I get is

]([![points not lotted]1)

After doing some google search and going through the code of dispersion_plot() function (https://www.nltk.org/_modules/nltk/draw/dispersion.html), I found that it uses "b|" as its line style in plot() function. But as per matplotlib documentation there are only four line styles possible {'-', '--', '-.', ':'} (https://matplotlib.org/gallery/lines_bars_and_markers/line_styles_reference.html).

So my doubt is whether line-style "|" was there earlier but has been removed now because of which dispersion_plot() is unable to draw plots or is there some other reason.

And also what is the workaround for this problem?

1

There are 1 answers

0
Adam Zawel On

I had a similar issue with my dispersion_plot (the problem appeared when I ran Jupyter on Google Collaboratory).

This cleared it up:

plt.style.use('default')