Skip to content

Commit

Permalink
Fix order of words in y-axis of dispersion_plot (#3150)
Browse files Browse the repository at this point in the history
* Update dispersion.py

Fix order of words in y-axis of dispersion_plot

* Fix dispersion_plot y-axis labels

Reverse input words list
  • Loading branch information
chbrandt committed May 8, 2023
1 parent 56bc4af commit 5ce90e9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nltk/draw/dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def dispersion_plot(text, words, ignore_case=False, title="Lexical Dispersion Pl
xs.append(x)
ys.append(y)

words = words[::-1]

_, ax = plt.subplots()
ax.plot(xs, ys, "|")
ax.set_yticks(list(range(len(words))), words, color="C0")
Expand Down

0 comments on commit 5ce90e9

Please sign in to comment.