Skip to content

Commit 59a1dbc

Browse files
authored
Merge pull request nltk#3158 from dlukes/feature/dispersion-plot-xaxis
Make sure dispersion plot spans full text length
2 parents be2e62e + 747e0ef commit 59a1dbc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
- Tom Lippincott
111111
- Peter Ljunglöf
112112
- Alex Louden
113+
- David Lukeš
113114
- Joseph Lynch
114115
- Nitin Madnani
115116
- Felipe Madrigal

nltk/draw/dispersion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def dispersion_plot(text, words, ignore_case=False, title="Lexical Dispersion Pl
4848

4949
_, ax = plt.subplots()
5050
ax.plot(xs, ys, "|")
51+
ax.dataLim.x0, ax.dataLim.x1 = 0, len(text) - 1
52+
ax.autoscale(axis="x")
5153
ax.set_yticks(list(range(len(words))), words, color="C0")
5254
ax.set_ylim(-1, len(words))
5355
ax.set_title(title)

0 commit comments

Comments
 (0)