3D表面形状的绘制、3D条状图、3D直线(曲线)的绘制
程序员文章站
2022-03-25 13:49:06
...
3D表面形状的绘制
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')
# Make data
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
# Plot the surface
ax.plot_surface(x, y, z, color='b')
plt.show()
3D条状图
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')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
xs = np.arange(20)
ys = np.random.rand(20)
# You can provide either a single color or an array. To demonstrate this,
# the first bar of each set will be colored cyan.
cs = [c] * len(xs)
cs[0] = 'c'
ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
3D直线(曲线)的绘制
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, label='parametric curve')
ax.legend()
plt.show()
上一篇: VueRouter动态路由匹配
下一篇: 安卓逐帧动画
推荐阅读
-
jQuery插件FusionCharts绘制的3D饼状图效果实例【附demo源码下载】
-
ai怎么绘制3d立体的曲线图表?
-
在Vue中使用highCharts绘制3d饼图的方法
-
jQuery插件FusionCharts绘制的3D双柱状图效果示例【附demo源码】
-
Pytorch练习--使用Axes3D的库绘制3D的Loss曲线
-
Illustrator绘制3D立体形状的小方块教程
-
AI怎么设计立体的饼图? ai绘制3d饼形图的教程
-
ai怎么绘制3D立体分离的饼形图? ai饼形图的绘制方法
-
php使用Jpgraph绘制3D饼状图的方法_PHP
-
jQuery插件FusionCharts绘制的3D饼状图效果实例【附demo源码下载】