Python 在pandas中运行数据帧的plot()

Python 在pandas中运行数据帧的plot(),python,matplotlib,pandas,fonts,Python,Matplotlib,Pandas,Fonts,当我在pandas中绘制数据帧时,我得到以下错误 /usr/lib/python3/dist-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['monospace'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) /u

当我在pandas中绘制数据帧时,我得到以下错误

   /usr/lib/python3/dist-packages/matplotlib/font_manager.py:1236: UserWarning: findfont: Font family ['monospace'] not found. Falling back to Bitstream Vera Sans
      (prop.get_family(), self.defaultFamily[fontext]))
    /usr/lib/python3/dist-packages/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=medium. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmex10.ttf
      UserWarning)
    /usr/lib/python3/dist-packages/matplotlib/font_manager.py:1246: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=large. Returning /usr/share/matplotlib/mpl-data/fonts/ttf/cmex10.ttf
      UserWarning)

感谢您的帮助:)

回复:鲍勃·哈夫纳的评论。您可以检查是否安装了monospace字体

import matplotlib
matplotlib.font_manager.findfont('monospace')
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/mpl-data/fonts/ttf/VeraMono.ttf
这就是我的matplotlib查找字体的地方,并找到了它。我怀疑,如果你这样做,你可能会得到一个类似的错误,上面的一个


我认为您可以链接到如下特定的字体文件:

我认为您试图使用一种您没有的字体(monospace),因此会收到一条警告,提示matplotlib将使用另一种字体。有什么情节吗?@BobHaffner是的,图表很好,但所有标签都变成了混乱的代码。如何在matplotlib中安装这些字体?除了@farenorth的问题,您如何设置字体系列?如何安装matplotlib?您是否通过pip或apt get安装了它(如果您使用的是基于Debian的机器)?@farenorth我的操作系统未使用2014车型年款解释器输出:
----------------------------------------------------------------AttributeError Traceback(最近一次调用最后一次)in()1导入matplotlib-->2 matplotlib.font\u manager.findfont('monospace')AttributeError:'module'对象没有属性'font\u manager'
请改用此导入语句。导入matplotlib.font_manager@BobHaffner好的,这次我的输出是
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
,没有错误信息。但是当我在pandas中使用
plot()
时,错误信息仍然显示为OK,我很惊讶。与@tandy一样,我认为这会给您一个错误:“如果matplotlib的版本为1.3或更低,请使用pd.options.display.mpl_style='default'将display.mpl_样式设置为'default',以生成更吸引人的绘图。设置后,matplotlib的rcParams会(全局!)更改为外观更好的设置。”能否在脚本顶部设置pd.options.display.mpl_style='default'并尝试重新运行?如果不是这个,你能试试=False吗?另外,请将导入内容和代码粘贴到.plot()前,谢谢!