gca and latest version of Matplotlib September 7, 2023 by Tarik You can try: fig = plt.figure() ax = fig.add_subplot(projection='3d')