我有一个x,y,z点的列表以及分配给每个3D点的值的列表。 现在的问题是,如何根据值列表为3D散点图中的每个点着色?
颜色应该是典型的工程-> RGB->最低的蓝色到最高的红色
非常感谢
基本上,我正在搜索等效于:scatter3(X,Y,Z,S,C) 看到这里:https://ch.mathworks.com/help/matlab/ref/scatter3.html
我尝试过:
col = [i/max(values)*255 for i in values]
ax.scatter(sequence_containing_x_vals, sequence_containing_y_vals, sequence_containing_z_vals,c=col, marker='o')
pyplot.show()
..但是我没有得到想要的结果
答案 0 :(得分:1)
您可以简单地做到:
cmap = plt.cm.get_cmap('jet')
col = [cmap(i/max(values)) for i in values]
答案 1 :(得分:1)
请注意,建议使用颜色生成散点图的方法是将值直接提供给attacked_switches
:
def start():
try:
number_of_switches, number_of_hosts = topology_info()
switch_dpids = list()
hosts = dict()
switch_dpids = switch_info(number_of_switches, switch_dpids)
hosts = host_info(number_of_hosts, hosts)
dpid = switch_byte(number_of_switches, switch_dpids)
print 'dpid= ', dpid
if dpid != 0:
print'calling flow pusher'
global attack
attack = True
attacked_switches.add(dpid)
T2 = threading.Thread(target=Flowpusher, args=[dpid])
T2.start()
elif attack:
T3 = threading.Thread(target=Flowremover, args=[dpid])
T3.start()
except Exception as e:
print'Error occured:', e
最小示例:
c