0

I want to know all the coordinates of this plot:

enter image description here

Source: http://matplotlib.org/examples/mplot3d/surface3d_demo2.html

enter image description here

Source: https://stackoverflow.com/a/11156353/3755171

And plot it as a sphere of dots(Consider only one of them, I can't find that kind):

enter image description here

OR Even the Matrix will Do.

When I tried to plot the above mentioned ones I got:

enter image description here

MY CODE

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)

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_wireframe(x, y, z, color="r")

#ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')
ax.plot(x,y,z,"o")

plt.show()
Community
  • 1
  • 1
Devashish Das
  • 241
  • 7
  • 19

1 Answers1

2

If you replace the call to plot with scatter as shown below then you will re-create a sphere composed entirely of points. See documentation here.

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
ax = Axes3D(fig)

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_wireframe(x, y, z, color="r")

#ax.plot_surface(x, y, z,  rstride=4, cstride=4, color='b')
ax.scatter(x,y,z,"o")

plt.show()

Image

Ffisegydd
  • 51,807
  • 15
  • 147
  • 125