0

I am trying some of the pandas plotting stuff shown here. However whenever I try to use the following command to set style options as suggested

pd.options.display.mpl_style = 'default'

I get the following errors

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

In working through my test code I have identified that when I add the pd.options line the errors are generated. Any reason for this? I have updated numpy, pandas, and matplotlib to their latest versions using pip --upgrade

sedavidw
  • 11,116
  • 13
  • 61
  • 95
  • Not sure exactly what's causing the error, but the most recent version of matplotlib added a [style package](http://matplotlib.org/users/whats_new.html#style-package-added) that accomplishes a lot of what the pandas option does. – TomAugspurger Oct 02 '14 at 01:43
  • Any tips on how to use it? – sedavidw Oct 02 '14 at 01:50

1 Answers1

2

This is the same issue as https://github.com/matplotlib/matplotlib/issues/3470 The issue is that due to a subtle oversight in the rcparams validation, what the macOSX backend expects to be a list of unicode objects is a list of byte-string objects, hence things blow up.

The simplest work-around is to use any other backend than the macosx backend. There is a patch in progress (https://github.com/matplotlib/matplotlib/pull/3564), but it has turned into a quagmire of other subtle bugs.

Still trying to decide if this needs to be a blocker on 1.4.1.

tacaswell
  • 84,579
  • 22
  • 210
  • 199
  • Thanks for the answer, do you know what's the latest version of matplotlib that does not have this issue? – sedavidw Oct 02 '14 at 13:35
  • 1.3.1 (which is pre-sixification) and 1.4.1 when in comes out ('soon', I think this is a blocker). If you are game, compiling from source off of this branch (https://github.com/matplotlib/matplotlib/pull/3564) would be awesome (I don't have a mac to test). – tacaswell Oct 02 '14 at 13:40