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

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

我正在使用 ipython 3.2.0,并且正在尝试使用箱线图。在线文档和示例建议关键字 "labels" 应该存在,正如此 post 中所述,但我收到以下错误:

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

是否删除了标签关键字?如果是这样,获得箱线图图例的官方方式是什么?

https://github.com/matplotlib/matplotlib/pull/2643, first shipped with mpl v1.4.0 and is still present on master 中添加了 labels kwarg。

问题已解决,完整总结如下:

  1. 正如 tcaswell 所述,labels 命令从 1.4.0 开始可用。
  2. "sudo pip install --upgrade ipython" 仅更新 ipython
  3. 我的错误是假设 matplotlib 是 matplotlib 的 "dependency",并且 pip 也会升级它,类似于 apt
  4. "sudo pip install --upgrade matplotlib" 有效,但在 ipython 启动时导致错误 "ImportError: cannot import name _tkagg"。
  5. 根据说明 here,删除 matplotlib,安装包 tk 和 tk-dev,然后重新安装 matplotlib,解决了 _tkagg 错误

该解决方案对我不起作用(Python 33 on Windows)。 我找到了另一种方法并把它留在这里以防其他人可能需要它:

  1. 卸载旧版本:pip uninstall matplotlib
  2. 从这里下载 wheel 文件https://pypi.python.org/pypi/matplotlib/1.4.3
  3. 运行 点安装 path_to_whl_file