代码拉取完成,页面将自动刷新
同步操作将从 shiyuxin233/My Machine Learning 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from mpl_toolkits import mplot3d
from matplotlib.pylab import *
plt.style.use('ggplot')
fig, ax = plt.figure(), plt.axes(projection='3d')
# 画一个莫比乌斯带
theta = linspace(0, 2 * pi, 30)
w = linspace(-0.25, 0.25, 8)
w, theta = meshgrid(w, theta)
phi = 0.5 * theta
r = 1 + w * cos(phi)
x = ravel(r * cos(theta))
y = ravel(r * sin(theta))
z = ravel(w * sin(phi))
from matplotlib.tri import Triangulation
tri = Triangulation(ravel(w), ravel(theta))
ax.plot_trisurf(x, y, z, triangles=tri.triangles, cmap='viridis')
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.set_zlim(-1, 1)
fig.colorbar(cm.ScalarMappable())
fig.show()
# 曲面三角剖分
# theta = 2 * pi * random(1000)
# r = 6 * random(1000)
# x = r * sin(theta)
# y = r * cos(theta)
# z = sin(sqrt(x ** 2 + y ** 2))
#
# ax.plot_trisurf(x, y, z, cmap='viridis')
# fig.colorbar(cm.ScalarMappable())
# 在曲面图中使用极坐标
# r = linspace(-5, 5, 30)
# theta = np.linspace(0, 0.75 * pi, 40)
# r, theta = meshgrid(r, theta)
#
# X = r * sin(theta)
# Y = r * cos(theta)
# Z = sin(sqrt(X ** 2 + Y ** 2))
# ax.plot_surface(X, Y, Z, cmap='viridis')
# fig.colorbar(cm.ScalarMappable())
# 网格图和曲面图
# x = linspace(-5, 5, 100)
# X, Y = meshgrid(x, x)
# Z = sin(sqrt(X ** 2 + Y ** 2))
# ax.plot_surface(X, Y, Z, cmap='viridis')
# ax.set_title('surface')
# 等高线图
# x = linspace(-5, 5, 100)
# X, Y = meshgrid(x, x)
# Z = sin(sqrt(X ** 2 + Y ** 2))
#
# ax.contour3D(X, Y, Z, 100, cmap='viridis')
# ax.set_xlabel('x')
# ax.set_ylabel('y')
# ax.set_zlabel('z')
# ax.view_init(60, 35) # 调整视角
# fig.colorbar(cm.ScalarMappable())
# line and dot
# x = linspace(0, 10, 1000)
# y = sin(x)
# z = cos(x)
#
# ax.plot3D(x, y, z)
#
# x_data = 15 * np.random.random(100)
# y_data = sin(x_data) + 0.1 * np.random.randn(100)
# z_data = cos(x_data) + 0.1 * np.random.randn(100)
#
# ax.scatter3D(x_data, y_data, z_data, c=z_data, cmap='viridis')
#
# fig.colorbar(cm.ScalarMappable())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。