Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: FigureBase.gca() got an unexpected keyword argument 'projection'

axes1 = fig.gca(projection = '3d')

1 axes1 = fig.add_axes(Axes3D(fig))
2 axes1 = fig.gca(projection=Axes3D.name)
3 axes1 = fig.add_subplot(projection='3d')

These are all the solutions i found during google, the first is the origional type of code, but was unusable after matplotlib 3.4 but the other 3 solution works differently with the first one

it's what I expected:

it's what i expected

it's the 1th:

it's the 1th

like image 569
marx Avatar asked Dec 02 '25 09:12

marx


1 Answers

This error happens due to Matplotlib update.

You can use

axes1 = fig.add_subplot(projection = '3d')

instead of

axes1 = fig.gca(projection = '3d') 

Reference: Plot 2D data on 3D plot

like image 58
Renyi Avatar answered Dec 04 '25 00:12

Renyi



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!