在最近的ubuntu更新后,我无法在matplotlib中绘制子图。不完全确定更新的内容并导致此问题。我的版本是ubuntu 17.04,matplotlib 2.0.0,python 2.7。有谁知道可能是什么原因?
我只是尝试过:
from matplotlib import pyplot as plt
fig, axs = plt.subplots(3,3)
导致:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 1212, in subplots
ax0 = fig.add_subplot(gs[0, 0], **subplot_kw)
File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1020, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_subplots.py", line 73, in __init__
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 529, in __init__
self._init_axis()
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 625, in _init_axis
self.yaxis = maxis.YAxis(self)
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 676, in __init__
self.cla()
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 760, in cla
self.reset_ticks()
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 774, in reset_ticks
self.majorTicks.extend([self._get_tick(major=True)])
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 2057, in _get_tick
return YTick(self.axes, 0, '', major=major, **tick_kw)
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 148, in __init__
self.apply_tickdir(tickdir)
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 512, in apply_tickdir
self._pad = self._base_pad + self.get_tick_padding()
File "/usr/lib/python2.7/dist-packages/matplotlib/axis.py", line 184, in get_tick_padding
return self._size * padding[self._tickdir]
KeyError: u'our
答案 0 :(得分:0)
这就是诀窍!谢谢ImportanceOfBeingErnest :) 我做了:
sudo -H pip uninstall matplotlib
sudo -H pip install matplotlib
现在再次运作。