【发布时间】:2015-04-07 17:27:38
【问题描述】:
我正在尝试在 ipython notebook 中内联绘制图形,但 .plot() methos 只显示对象信息,如
<matplotlib.axes._subplots.AxesSubplot at 0x10d8740d0>
但没有图表。我也可以用plt.show() 让它显示图形,但我想内联。所以我尝试了%matplotlib inline 和ipython notebook --matplotlib=inline,但没有任何帮助。
如果我使用%matplotlib inline,则显示.plot()
/Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/formatters.py:239:
FormatterWarning: Exception in image/png formatter: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) FormatterWarning,
并且使用ipython notebook --matplotlib=inline 显示相同。
【问题讨论】:
-
认为我们需要更多信息,展示您的代码、导入和平台...
-
您在使用
% matplotlib inline时描述的错误是由于处理Unicode 和字符串的问题。可能,您有用latin-1编码的字符,并且转换正在尝试使用decode。但是,decode正在使用默认编码ascii将您的字符转换为 unicode,并且由于在 ascii 中找不到该字符,因此转换失败。在将数据传递给 matplotlib 之前,您应该尝试使用 decode ("\xe2".decode(encoding='latin-1')) 将字符串转换为 unicode。
标签: python matplotlib pandas plot ipython-notebook