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?
在这个问题中,我们展示了如何绘制(在许多其他事物中)一个球体:Python / matplotlib:绘制一个三维立方体,一个球体和一个向量?
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?
这是非常好的,但我想以这样的方式绘制线框球体,使得视线之外的平行线和经线(由球体本身隐藏)不会出现。用python脚本可以吗?
Thanks.
谢谢。
1 个解决方案
#1
1
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()
#1
1
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()