python - 绘制 3D 图形时出现问题,错误无法重塑数组,无法将大小为 712 的数组重塑为形状 (712,3)
问题描述
我在绘制 3D 图表时遇到问题。我有由 713 行和 3 列组成的 csv 文件
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,3), np.array(y).reshape(712,3), np.array(z).reshape(712,3),
cmap='viridis', edgecolor='none')
#ax.plot_surface(x, y, z,cmap='viridis', edgecolor='none')
plt.show()
错误
ax.plot_surface(np.array(x).reshape(712,3), np.array(y).reshape(712,3), np.array(z).reshape(712,3), cmap='viridis', edgecolor='none')
ValueError: cannot reshape array of size 712 into shape (712,3)
解决方案
推荐阅读
- c - 使用 Makefile 编译任何单个 C 代码
- c - C 新手尝试进行循环。Realloc():无效的下一个大小问题
- ios - Swift-调整约束以允许键盘
- flutter - formdata在颤动中转换为字符串
- python - 如何遍历文件的每一行并打印出任何包含两个相邻元音的单词?
- html - 有没有办法让这个 H1 在 div 的底部居中?
- python - 使用 Python 删除 Gmail 中的特定电子邮件
- python - 如何在类方法中就地更改列表元素
- yii2 - 如何在 yii2 gii 生成的 crud 中添加自定义新字段
- python - 具有柱式变压器和管道的 ML 模型的参数调整