I am trying to plot a full cylinder, using a cylindrical mesh grid. However I just managed to get half a cylinder. Here is my code
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
r = 1
x = np.linspace(-r, r, 50)
y = np.linspace(-r, r, 50)
X, Y = np.meshgrid(x, y)
Z = (np.pi * -Y**2)
surf = ax.plot_surface(X, Y, Z)
What I would like to obtain is something like this
Could anybody give me some insights on how to do it?
In this post the ax.plot_surface function is called twice. In your case adding a minus sign to the Z does not yet result in a cylinder, but at least you have a top and bottom part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.