diff --git a/AUTHORS.md b/AUTHORS.md index eef7f03b25..e4156ab79e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -253,7 +253,7 @@ - Viresh Gupta - Ondřej Cífka - Iris X. Zhou - +- Josh Bell ## Others whose work we've taken and included in NLTK, but who didn't directly contribute it: ### Contributors to the Porter Stemmer diff --git a/nltk/probability.py b/nltk/probability.py index 80ee1180de..9bf9af854f 100755 --- a/nltk/probability.py +++ b/nltk/probability.py @@ -1894,7 +1894,7 @@ def plot(self, *args, **kwargs): """ Plot the given samples from the conditional frequency distribution. For a cumulative plot, specify cumulative=True. - (Requires Matplotlib to be installed.) + (Requires matplotlib to be installed.) :param samples: The samples to plot :type samples: list @@ -1904,25 +1904,24 @@ 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.' 'See http://matplotlib.org/' ) - cumulative = _get_kwarg(kwargs, 'cumulative', False) percents = _get_kwarg(kwargs, 'percents', False) conditions = _get_kwarg(kwargs, 'conditions', sorted(self.conditions())) 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])) - ) # this computation could be wasted + for v in self[c])) + ) # 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)) @@ -1942,9 +1941,9 @@ 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) + plt.xticks(range(len(samples)), [text_type(s) for s in samples]) if title: - ax.set_title(title) + ax.title(title) ax.set_xlabel("Samples") ax.set_ylabel(ylabel) plt.show()