'matplotlib.axes.Axes.set_xticks throws "set_ticks() takes 2 positional arguments but 3 were given"

this easy example from matplotlib throws the mentioned error:

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

I also cannot find any typo according to the documentation of set_xticks():

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

Can anyone provide clearification and some help, please?

Kind regards, Daniel



Solution 1:[1]

In my case I had forgotten to activate my Python virtual environment, so the interpreter was referencing an older version of matplotlib with no function named set_xticks.

Running pipenv shell before starting my script fixed the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1