简体   繁体   中英

TypeError: boxplot() got an unexpected keyword argument 'labels'

I'm using ipython 3.2.0, and I'm trying to use boxplot. Online documentation and examples suggest that a keyword "labels" should exist, as also stated in this SO post, but I get the following error:

TypeError: boxplot() got an unexpected keyword argument 'labels'

Was the labels keyword removed? If so, what is the official way to get a legend for a boxplot?

labels kwarg添加在https://github.com/matplotlib/matplotlib/pull/2643中 ,首先附带mpl v1.4.0并且仍然存在于主服务器上

The solution did not work for me (Python 33 on Windows). I found another way and leave it here just in case someone else may need it:

  1. Uninstall the old version: pip uninstall matplotlib
  2. Download the wheel file from here https://pypi.python.org/pypi/matplotlib/1.4.3
  3. Run pip install path_to_whl_file

The problem is resolved, here is a complete summary:

  1. The labels command has been available since 1.4.0 as tcaswell states.
  2. "sudo pip install --upgrade ipython" updates only ipython
  3. My mistake was assuming that matplotlib was a "dependency" of matplotlib, and that pip would upgrade it as well, similar to apt
  4. "sudo pip install --upgrade matplotlib" worked, but lead to the error "ImportError: cannot import name _tkagg" when ipython starts.
  5. Per the instructions here , removing matplotlib, installing the packages tk and tk-dev, and reinstalling matplotlib, resolved the _tkagg error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM