matplotlib.axes.Axes.set_xticks 抛出“set_ticks() 需要 2 个位置参数,但给出了 3 个”

dan*_*732 10 python matplotlib

matplotlib 中的这个简单示例会引发上述错误:

https://matplotlib.org/stable/gallery/lines_bars_and_markers/barchart.html

根据 set_xticks() 的文档,我也找不到任何拼写错误:

https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xticks.html

有人可以提供澄清和一些帮助吗?

亲切的问候,丹尼尔

Ger*_*uli 12

此错误基于您使用的 matplotlib 版本。该set_axis命令已从 matplotlib 版本 3.4.x 更改为 3.5.x。尝试使用较新的版本。您可以通过安装它

$ pip install matplotlib==3.5.0
Run Code Online (Sandbox Code Playgroud)