ax = plt.gca(projection='3d')

is deprecated in new version vo matplotlib use

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

instead