Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix #2325

Closed
wants to merge 1 commit into from
Closed

bug fix #2325

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions nltk/probability.py
Expand Up @@ -1904,7 +1904,7 @@ def plot(self, *args, **kwargs):
:type conditions: list
"""
try:
from matplotlib import plt
import matplotlib.pyplot as plt
except ImportError:
raise ValueError(
'The plot function requires matplotlib to be installed.'
Expand All @@ -1917,12 +1917,12 @@ def plot(self, *args, **kwargs):
title = _get_kwarg(kwargs, 'title', '')
samples = _get_kwarg(
kwargs, 'samples', sorted(set(v for c in conditions
if v in self
for v in self[c]))
for v in self[c]
if v in self))
) # this computation could be wasted
if "linewidth" not in kwargs:
kwargs["linewidth"] = 2

ax = plt.gca()
for condition in conditions:
if cumulative:
freqs = list(self[condition]._cumulative_frequencies(samples))
Expand All @@ -1942,7 +1942,7 @@ def plot(self, *args, **kwargs):

ax.legend(loc=legend_loc)
ax.grid(True, color="silver")
ax.set_xticks(range(len(samples)), [text_type(s) for s in samples], rotation=90)
ax.set_xticklabels([text_type(s) for s in samples])
if title:
ax.set_title(title)
ax.set_xlabel("Samples")
Expand Down