Pandas绘制选项导致iPython出错

时间:2014-10-02 01:38:10

标签: python matplotlib pandas

我正在尝试绘制一些显示here内容的大熊猫。但是每当我尝试使用以下命令按照建议设置样式选项时

pd.options.display.mpl_style = 'default'

我收到以下错误

In [6]: Traceback (most recent call last):
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/figure.py", line 1079, in draw
    func(*args)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/axis.py", line 1105, in draw
    renderer)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/axis.py", line 1054, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/text.py", line 741, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/text.py", line 311, in _get_layout
    ismath=False)
  File "/Users/seanwhipple/py27/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 166, in get_text_width_height_descent
    six.text_type(s), family, size, weight, style)
TypeError: bad argument type for built-in operation

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

在处理我的测试代码时,我发现当我添加pd.options行时会生成错误。有什么理由吗?我已使用numpy

pandasmatplotlibpip --upgrade更新为最新版本

1 个答案:

答案 0 :(得分:2)

这与https://github.com/matplotlib/matplotlib/issues/3470的问题相同。问题在于,由于rcparams验证中的细微疏忽,macOSX后端期望成为unicode对象列表的是字节串对象列表,因此事情爆发了。

最简单的解决方法是使用除macosx后端之外的任何其他后端。正在进行补丁(https://github.com/matplotlib/matplotlib/pull/3564),但它已经变成了其他微妙错误的泥潭。

仍在尝试确定这是否需要成为1.4.1的拦截器。