【发布时间】: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