我正在尝试绘制一个 3d 图形,代码运行良好,但该图形附加了空快照。我有 还共享图形数据 csv 文件 https://drive.google.com/file/d/1dohDHX7mJKliF8X2xowCqRURQOuQE0Ip/view?usp=sharing 。
data = np.genfromtxt("graph-data.csv", delimiter=",", names=["x", "y","z"])
x, y, z = zip(*data)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.set_xlabel('CPU availability(%)')
ax.set_ylabel('Memory availability(%)')
ax.set_zlabel('Frame Drop Rate(%)')
ax.plot_surface(np.array(x).reshape(712,1), np.array(y).reshape(712,1), np.array(z).reshape(712,1),
cmap='viridis', edgecolor='none')
#ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
plt.show()
提前致谢
答案 0 :(得分:1)
您可以使用 trisurf,您的代码变为(注意我删除了 reshape
函数)
data = np.genfromtxt("graph-data.csv", delimiter=",", names=["x", "y","z"])
x, y, z = zip(*data)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.set_xlabel('CPU availability(%)')
ax.set_ylabel('Memory availability(%)')
ax.set_zlabel('Frame Drop Rate(%)')
ax.plot_trisurf(np.array(x), np.array(y), np.array(z), cmap='viridis', edgecolor='none')
plt.show()