【问题标题】:Plot colour of 3D point based actual value of each data point根据每个数据点的实际值绘制 3D 点的颜色
【发布时间】:2019-07-19 00:28:51
【问题描述】:

我有一个 3D 斜坡数组,X。 我想绘制每个数据点并根据实际值对点进行颜色编码。有三个可能的值。

如果斜率大于 80,则将数据点绘制为红色。如果斜率大于 -80 则为蓝色,否则为绿色。

我也想要传说。 谢谢

我尝试创建了一些东西,但没有做对。

#Make the array to 2D with X, Y, Z axis
X=fits.transpose(2,0,1).reshape(-1,3)
print(X.shape)


kcolors = ['red' if slope greater 0.2  elif slope greater -0.2 'green'  else 'blue' for slope in X]

plt.scatter(transformed[:,0], transformed[:,1], transformed[:,2], c=kcolors)


File "<ipython-input-26-4efc22ca2a34>", line 6
kcolors = ['red' if slope > 0.2  elif slope > -0.2 'green'  else 'blue' for slope in points]

SyntaxError: 无效语法

【问题讨论】:

    标签: python-3.x plot scatter-plot


    【解决方案1】:

    我试过了

    colors = []
    for slope in Xpoints[0]:
        if slope > 0.2:
            colors.append('r')
        elif slope < -0.2:
            colors.append('g') 
        else:
            colors.append('b')
    

    这似乎有效。 有没有更好的方法?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-15
      • 1970-01-01
      相关资源
      最近更新 更多