I would like to build the surface of my data, which is defined by three-dimensional vectors in the Cartesian coordinates x, y, z. Data cannot be represented by a smooth function.
So, first we generate some dummy data using a function eq_points(N_count, r)
that returns an array points
with the x, y, z coordinates of each point on the surface of our object. Value omega
is a solid angle, not now.
def eq_points(N_count, r):
points = []
a = 4*np.pi*r**2/N_count
d = np.sqrt(a)
M_theta = int(np.pi/d)
d_theta = np.pi/M_theta
d_phi = a/d_theta
for m in range(M_theta):
theta = np.pi*(m+0.5)/M_theta
M_phi = int(2*np.pi*np.sin(theta)/d_phi)
for n in range(M_phi):
phi = 2*np.pi*n/M_phi
points.append(np.array([r*np.sin(theta)*np.cos(phi),
r*np.sin(theta)*np.sin(phi),
r*np.cos(theta)]))
omega = 4*np.pi/N_count
return np.array(points), omega
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
points, omega = eq_points(400, 1.)
ax.scatter(points[:,0], points[:,1], points[:,2])
ax.scatter(0., 0., 0., c="r")
ax.set_xlabel(r'$x$ axis')
ax.set_ylabel(r'$y$ axis')
ax.set_zlabel(r'$Z$ axis')
plt.savefig("./sphere.png", format="png", dpi=300)
plt.clf()
The result is the scope shown in the following figure.
Blue dots mark data from the array points
, and a red dot is the beginning.
-
. mplot3d . ax.scatter()
, .
, , , . . , , . , . plot_surface()
? :
