Reputation: 1267
In this question we are shown how to plot (among many other things) a sphere: Python/matplotlib : plotting a 3d cube, a sphere and a vector?
It's very nice but I would like to plot the wireframe sphere in such a way that the parallels and meridians that are outside the line of vision (hidden by the sphere itself) don't appear. Is that possible with a python script?
Thanks.
Upvotes: 3
Views: 3083
Reputation: 339340
The idea of a wireframe plot is to make is see-through such that features behind the object are still visible.
So instead of a wireframe you probably want to plot a surface plot:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("equal")
# draw sphere
u, v = np.mgrid[0:2*np.pi:20j, 0:np.pi:10j]
x = np.cos(u)*np.sin(v)
y = np.sin(u)*np.sin(v)
z = np.cos(v)
ax.plot_surface(x, y, z, color="w", edgecolor="r")
plt.show()
Upvotes: 3