0

私が実行しているpythonとmatplotlibに問題があります

from matplotlib import rc
import matplotlib.cm as cm
from matplotlib.ticker import MultipleLocator


scoreArray = [3,8,7,8,9,0]
scoreArrayIsopmap = [3,4,7,1,3,0]
scoreArrayPCA = [0,1,7,6,3,15]

rc('font',**{'family':'Bitstream Vera Sans','serif': ['Palatino']})
rc('text', usetex=True)

fig, (ax1) = plt.subplots(1,1, figsize=(7,5))

ax1.plot(range(0,6), scoreArray, color = 'b', ls='-', lw=4, alpha=0.7, label="A Priori Manifold")
ax1.plot(range(0,6), scoreArrayIsopmap, color = 'r', ls='-', lw=4, alpha=0.7, label="Isomap")
ax1.plot(range(0,6), scoreArrayPCA, color = 'g', ls='-', lw=4, alpha=0.7, label="PCA")

ax1.xaxis.set_major_locator(MultipleLocator(10))
ax1.grid(which='major', axis='x', linewidth=0.25, linestyle='-', color='0.75') 
ax1.grid(True) 
ax1.set_ylabel('Dunn Index') 
ax1.set_xlabel('Number Of Components')

ここに画像の説明を入力

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

1419             self.set_frameon(frameon)
1420 
-> 1421         self.canvas.print_figure(*args, **kwargs)
1422 
1423         if frameon:

/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self,    filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2218                 orientation=orientation,
2219                 bbox_inches_restore=_bbox_inches_restore,
-> 2220                 **kwargs)
2221         finally:
2222             if bbox_inches and restore_bbox:

/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_pdf(self, *args, **kwargs)
1950         from backends.backend_pdf import FigureCanvasPdf  # lazy import
1951         pdf = self.switch_backends(FigureCanvasPdf)
-> 1952         return pdf.print_pdf(*args, **kwargs)
1953 
1954     def print_pgf(self, *args, **kwargs):

/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyc in print_pdf(self, filename, **kwargs)
2338                                          width, height, image_dpi, RendererPdf(file, image_dpi),
2339                                          bbox_inches_restore=_bbox_inches_restore)
-> 2340             self.figure.draw(renderer)
2341             renderer.finalize()
2342         finally:

/usr/local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
52     def draw_wrapper(artist, renderer, *args, **kwargs):
53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
55         after(artist, renderer)
56 

/usr/local/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
1032         dsu.sort(key=itemgetter(0))
1033         for zorder, a, func, args in dsu:
-> 1034             func(*args)
1035 
1036         renderer.close_group('figure')

/usr/local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
52     def draw_wrapper(artist, renderer, *args, **kwargs):
53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
55         after(artist, renderer)
56 

/usr/local/lib/python2.7/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe)
2084 
2085         for zorder, a in dsu:
-> 2086             a.draw(renderer)
2087 
2088         renderer.close_group('axes')

/usr/local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
52     def draw_wrapper(artist, renderer, *args, **kwargs):
53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
55         after(artist, renderer)
56 

/usr/local/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
1087         ticks_to_draw = self._update_ticks(renderer)
1088         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
-> 1089                                                                 renderer)
1090 
1091         for tick in ticks_to_draw:

/usr/local/lib/python2.7/site-packages/matplotlib/axis.pyc in _get_tick_bboxes(self, ticks, renderer)
1036         for tick in ticks:
1037             if tick.label1On and tick.label1.get_visible():
-> 1038                 extent = tick.label1.get_window_extent(renderer)
1039                 ticklabelBoxes.append(extent)
1040             if tick.label2On and tick.label2.get_visible():

/usr/local/lib/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
751             raise RuntimeError('Cannot get window extent w/o renderer')
752 
--> 753         bbox, info, descent = self._get_layout(self._renderer)
754         x, y = self.get_position()
755         x, y = self.get_transform().transform_point((x, y))

/usr/local/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)
318         tmp, lp_h, lp_bl = get_text_width_height_descent('lp',
319                                                          self._fontproperties,
--> 320                                                          ismath=False)
321         offsety = (lp_h - lp_bl) * self._linespacing
322 

/usr/local/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyc in    get_text_width_height_descent(self, s, prop, ismath)
1945     def get_text_width_height_descent(self, s, prop, ismath):
1946         if rcParams['text.usetex']:
-> 1947             texmanager = self.get_texmanager()
1948             fontsize = prop.get_size_in_points()
1949             w, h, d = texmanager.get_text_width_height_descent(s, fontsize,

/usr/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in get_texmanager(self)
612         if self._texmanager is None:
613             from matplotlib.texmanager import TexManager
--> 614             self._texmanager = TexManager()
615         return self._texmanager
616 

/usr/local/lib/python2.7/site-packages/matplotlib/texmanager.pyc in __init__(self)
170         if len(ff) == 1 and ff[0].lower() in self.font_families:
171             self.font_family = ff[0].lower()
--> 172         elif ff.lower() in self.font_families:
173             self.font_family = ff.lower()
174         else:

AttributeError: 'list' object has no attribute 'lower'

上の画像を取得しますが、軸が表示されません。私はpython 2.7.5とmatplotlib 1.3を実行しています。私は Mac で作業していますが、別の Mac でも問題なく動作します。2日前までは問題なく動作していました。

なぜこれが起こるのか誰にも分かりますか?

4

1 に答える 1

2

ここには 2 つのことがあります。

  1. matplotlib コードから:

    text.usetex が True の場合、font.family は (serif、sans-serif、cursive、monospace) のいずれかでなければなりません。デフォルトではセリフが使用されます。

    したがって、 を使用する場合は、 をサポートされている値の 1 つにtext.usetex設定する必要があります。font.family

  2. matplotlib 1.3.0 にバグが見つかりました :) しかし、開発ブランチでは既に修正されています。したがって、次のリリースではエラーは発生しません。

于 2013-09-19T10:05:33.170 に答える