From 50de154b515a19070d24b82d254b4906fe67cb10 Mon Sep 17 00:00:00 2001 From: XParallelUniverses <709456084@qq.com> Date: Sun, 23 Jun 2019 12:07:33 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nltk/probability.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nltk/probability.py b/nltk/probability.py index 80ee1180de..dcb283e268 100755 --- a/nltk/probability.py +++ b/nltk/probability.py @@ -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.' @@ -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)) @@ -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")