python-3.x - Matplotlib 中的三维绘图,点之间有一条线
问题描述
我在处理三个变量的第三维图时遇到问题。
我有三个矩阵:X、Y 和 Z,参数为这种类型:
(x_1, y_1, z_1)
(x_2, y_2, z_2)
.
(x_n, y_n, z_n)
我可以通过 scatter3D 绘图将它们显示在不同的点上。打击是我的代码,objective[0] 是 x,objective[1] 是 y,objective[2] 表示 z:
from mpl_toolkits import mplot3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.scatter3D([s.objectives[0] for s in algorithm.result],
[s.objectives[1] for s in algorithm.result],
[s.objectives[2] for s in algorithm.result])
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
但是,我的问题是当我想在点之间显示一条线时。我想在其中一个矩阵的变化方向上的点之间有一条线,例如 x。
我的意思是,如果我的目标是基于 x 并且假设 x 不断增加,我希望在具有 x_1 的点和具有 x_2 的点之间有一条线,然后在具有 x_2 的点和具有 x_3 的点之间有一条线。 ...
实际上,这条线显示了当 x 变化时(当 x 增加时)我的三个参数如何变化。
为此,我使用了 plot3D,blow 是我的代码:
ax.plot3D([s.objectives[0] for s in algorithm.result],
[s.objectives[1] for s in algorithm.result],
[s.objectives[2] for s in algorithm.result])
但在图中,我在每个点与所有其他点之间都有线。我的意思是 ((n*n-1)/2) 行而不是 n-1 行。
如何使用 mplot3d 实现我的目标?或其他方式。
解决方案
推荐阅读
- angular - 拖放不适用于 ag-grid-angular
- python - 我应该如何在 Travis 上使用 moto 测试 AWS S3?
- ocaml - ocamlc可以编译ml和mli以外的文件吗?
- spring - JPA 或 Hibernate 从数据库映射多个对象
- java - 如何使用私有内部类进行测试?
- javascript - Node.Js 函数在 promise 返回时调用一次时运行两次
- python-3.x - 如何获取适当形状的数据以馈送到 keras 中的 LSTM 层以进行序列到序列预测
- php - Yii2 Kartik-v fileiput:当包装在 $_FILES 数组中而不是 $_POST 时获取上传的图像
- python - 如何找出索引是否在嵌套列表中
- angular - “FormGroup”类型上不存在属性“第 1 节”。自动构建