Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib: AttributeError: 'AxesSubplot' object has no attribute 'add_axes'

Not sure exactly sure how to fix the following attribute error:

AttributeError: 'AxesSubplot' object has no attribute 'add_axes'

The offending problem seems to be linked to the way I have set up my plot:

gridspec_layout = gridspec.GridSpec(3,3)
pyplot_2 = fig.add_subplot(gridspec_layout[2])

ax = WCSAxes(fig, [0.1, 0.1, 0.8, 0.8], wcs=wcs)
pyplot_2.add_axes(ax)

Does anybody know how to solve this? Many thanks.


1 Answers

You now need to use set_prop_cycle i.e. ax.set_prop_cycle(color=['red', 'green', 'blue'])

Axes.set_color_cycle(clist) was depreciated since, version 1.5.

https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.axes.Axes.set_prop_cycle.html

like image 58
The Puternerd Avatar answered Sep 03 '25 09:09

The Puternerd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!