No, there is no such thing as a "sphere artist". And even if there was, it would not take less time to draw it.
The solution you present in the question is a sensible way to draw many spheres. However, you might want to consider using a lot less points on the sphere,
u = numpy.linspace(0, 2*numpy.pi, 12)
v = numpy.linspace(0, numpy.pi, 7)
An option one should always consider is not to use matplotlib for 3D plotting, as it is not actually been designed for it; and use Mayavi instead.
The above in mayavi would look like
from mayavi import mlab
import numpy as np
[phi,theta] = np.mgrid[0:2*np.pi:12j,0:np.pi:12j]
x = np.cos(phi)*np.sin(theta)
y = np.sin(phi)*np.sin(theta)
z = np.cos(theta)
def plot_sphere(p):
r,a,b,c = p
return mlab.mesh(r*x+a, r*y+b, r*z+c)
for k in range(200):
c = np.random.rand(4)
c[0] /= 10.
plot_sphere(c)
mlab.show()
While the calculation takes a similar time, interactively zooming or panning is much faster in Mayavi.
Furthermore Mayavi actually provides something like a "sphere artist", which is called points3d
from mayavi import mlab
import numpy as np
c = np.random.rand(200,3)
r = np.random.rand(200)/10.
mlab.points3d(c[:,0],c[:,1],c[:,2],r)
mlab.show()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…