python - 如何在 Python 中保存绘图图形
问题描述
我有这段代码,其中 c_X,c_Y,c_Z,X,Y,Z X_2,Y_2,Z_2,X_4,Y_4,Z_4 是点列表(我的数据)。
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
for i in range (2):
fig = plt.figure(i)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(c_X,c_Y,c_Z, color = 'midnightblue')
ax.scatter(X, Y, Z, color = 'mediumaquamarine')
ax.scatter(X_2,Y_2,Z_2, color = 'cadetblue')
ax.scatter(X_4,Y_4,Z_4, color = 'cadetblue')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.draw()
最后,我怎样才能持有或获得 3 个不同数字的 3 个地块?
解决方案
按照问题评论中的建议修改您的代码。
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
for i in range (2):
fig = plt.figure(i)
ax = fig.add_subplot(111, projection='3d')
ax.scatter(c_X,c_Y,c_Z, color = 'midnightblue')
ax.scatter(X, Y, Z, color = 'mediumaquamarine')
ax.scatter(X_2,Y_2,Z_2, color = 'cadetblue')
ax.scatter(X_4,Y_4,Z_4, color = 'cadetblue')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
我认为这可以满足您的要求。
推荐阅读
- python - 在 Python 中将字节数组转换为 16 位灰度图像
- mysql - 通过 SQL 中两个最大值的组合对 2 列进行排序
- snowflake-cloud-data-platform - 将 CSV 数据加载到雪花表
- python - Python Flask 和 Nginx-> 路由重定向
- python - 如何有效地删除熊猫中某些列的值高于 99% 的所有行?
- c++ - 第二次使用方法时访问冲突读取位置 0xFFFFFFF8
- r - 通过两个列表的复杂比较创建一个列表
- javascript - 页面刷新到屏幕阅读器时触发角色“警报”
- batch-file - 如何列出文件夹中的所有文件然后选择多个文件
- node.js - 使用 XLSX 按列读取值