matplotlib绘制三维折线图

如下代码:

import matplotlib as mpl
import numpy as np
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
 
fig = plt.figure()
ax = fig.gca(projection='3d')
plt.xlabel('ai')
plt.ylabel('bi')

x = np.random.randint(0,10,20) # 生成20个随机整数
y = np.random.randint(0,10,20)
z = x/(x+y)
ax.plot(x, y, z, 'go-', label='Curve', )
ax.legend()
plt.show()

绘图效果:
matplotlib绘制三维折线图_第1张图片

你可能感兴趣的:(python,matplotlib)