python 3D plot with xyz-axes

17 Views Asked by At

Standard python 3D plots put three "walls" in the background of the plot. Is there a way to make the standard "math-textbook" type 3D plot where instead of the three walls we have three coordinate axes? Here is a python program I hacked together that makes the 3D plot + 3 (positive) coordinate axes. Ideally I would like to have the negative part axes as well (without the arrows in the negative direction) and without the three "walls". THANKS!

from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
 
 
# Creating dataset
x = np.outer(np.linspace(-3, 3, 32), np.ones(32))
y = x.copy().T # transpose
z = (x*x - y*y)
 
# Creating figure
fig = plt.figure(figsize =(14, 9))
ax = plt.axes(projection ='3d')
 
# Creating plot
ax.plot_surface(x, y, z)

# Make a 3D quiver plot
x, y, z = np.zeros((3,3))
u, v, w = np.array([[5,0,0],[0,5,0],[0,0,5]])

ax.quiver(x,y,z,u,v,w,arrow_length_ratio=0.1,color='r')

# show plot
plt.show()
0

There are 0 best solutions below