【发布时间】:2012-06-01 18:16:08
【问题描述】:
我有大量数据,我正试图以 3D 形式表示,希望能发现一种模式。我花了很多时间阅读、研究和编码,但后来我意识到我的主要问题不是编程,而是实际上选择一种可视化数据的方式。
Matplotlib 的 mplot3d 提供了很多选项(线框、轮廓、填充轮廓等),MayaVi 也是如此。但是有这么多的选择(每个都有自己的学习曲线),我几乎迷失了,不知道从哪里开始!所以我的问题本质上是如果你必须处理这些数据,你会使用哪种绘图方法?
我的数据是基于日期的。对于每个时间点,我绘制一个值(列表“实际”)。
但是对于每个时间点,我也有一个上限、一个下限和一个中间点。这些限制和中点基于不同平面中的种子。
我想在我的“实际”阅读中发生重大变化时或之前找出要点或识别模式。是不是所有飞机的上限都满足的时候?还是互相接近?是在实际值触及上限/中值/下限时吗?是不是一个位面的Uppers碰到另一个位面的Lowers?
在我粘贴的代码中,我已将数据集缩减为几个元素。我只是使用简单的散点图和线图,但由于数据集的大小(可能还有 mplot3d 的限制?),我无法使用它来发现我正在寻找的趋势。
dates = [20110101,20110104,20110105,20110106,20110107,20110108,20110111,20110112]
zAxis0= [ 0, 0, 0, 0, 0, 0, 0, 0]
Actual= [ 1132, 1184, 1177, 950, 1066, 1098, 1116, 1211]
zAxis1= [ 1, 1, 1, 1, 1, 1, 1, 1]
Tops1 = [ 1156, 1250, 1156, 1187, 1187, 1187, 1156, 1156]
Mids1 = [ 1125, 1187, 1125, 1156, 1156, 1156, 1140, 1140]
Lows1 = [ 1093, 1125, 1093, 1125, 1125, 1125, 1125, 1125]
zAxis2= [ 2, 2, 2, 2, 2, 2, 2, 2]
Tops2 = [ 1125, 1125, 1125, 1125, 1125, 1250, 1062, 1250]
Mids2 = [ 1062, 1062, 1062, 1062, 1062, 1125, 1000, 1125]
Lows2 = [ 1000, 1000, 1000, 1000, 1000, 1000, 937, 1000]
zAxis3= [ 3, 3, 3, 3, 3, 3, 3, 3]
Tops3 = [ 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250]
Mids3 = [ 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187]
Lows3 = [ 1125, 1125, 1000, 1125, 1125, 1093, 1093, 1000]
import matplotlib.pyplot
from mpl_toolkits.mplot3d import Axes3D
fig = matplotlib.pyplot.figure()
ax = fig.add_subplot(111, projection = '3d')
#actual values
ax.scatter(dates, zAxis0, Actual, color = 'c', marker = 'o')
#Upper limits, Lower limts, and Mid-range for the FIRST plane
ax.plot(dates, zAxis1, Tops1, color = 'r')
ax.plot(dates, zAxis1, Mids1, color = 'y')
ax.plot(dates, zAxis1, Lows1, color = 'b')
#Upper limits, Lower limts, and Mid-range for the SECOND plane
ax.plot(dates, zAxis2, Tops2, color = 'r')
ax.plot(dates, zAxis2, Mids2, color = 'y')
ax.plot(dates, zAxis2, Lows2, color = 'b')
#Upper limits, Lower limts, and Mid-range for the THIRD plane
ax.plot(dates, zAxis3, Tops3, color = 'r')
ax.plot(dates, zAxis3, Mids3, color = 'y')
ax.plot(dates, zAxis3, Lows3, color = 'b')
#These two lines are just dummy data that plots transparent circles that
#occpuy the "wall" behind my actual plots, so that the last plane appears
#floating in 3D rather than being pasted to the plot's background
zAxis4= [ 4, 4, 4, 4, 4, 4, 4, 4]
ax.scatter(dates, zAxis4, Actual, color = 'w', marker = 'o', alpha=0)
matplotlib.pyplot.show()
我得到了这个情节,但它并不能帮助我看到任何共同关系。
我不是数学家或科学家,所以我真正需要的是帮助选择可视化数据的格式。有没有一种有效的方法可以在 mplot3d 中显示这一点?还是您会使用 MayaVis?无论哪种情况,您会使用哪个库和类?
提前致谢。
【问题讨论】:
-
如果您正在寻找相关性,3d 可能不是最好的方法。视角妨碍了解释。您可能想改用分面图、过度绘图和散点图。
标签: python r matplotlib mayavi mplot3d