0

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?

  • `"b|"` means "blue vertical marker". E.g. `plt.plot([1,2,4], "b|")` will look [like this](https://i.stack.imgur.com/domOA.png). So there is no error from this part. To find out why your code does not give the desired result you would need to show a [mcve] of the issue. – ImportanceOfBeingErnest Sep 27 '18 at 23:09

1 Answers1

2

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')

Adam Zawel
  • 21
  • 2