繁体   English   中英

plot 2 arrays 如何根据他们的曼哈顿距离相互对抗?

[英]How to plot 2 arrays against each other according to their Manhatten distance?

我有 4 个 arrays 即 a,b,c 和 d。 必须在同一 plot 中的 a、b 和 c、d 之间的每对值之间进行绘图,最好使用不同的标记。配色方案必须根据曼哈顿距离而变化。 我做了以下 -

a=[1,2,3]
b=[5,6,7]
c=[9,10,11]
d=[13,14,15]

distance1=[30,40,50]
distance2=[10,20,60]

The pairs to be plotted are (1,5),(2,6),(3,7) for a and b according to the distance array distance1. The other pairs are (9,10),(10,14),(11,15) for c and d according to the distance array distance 2.

我写了以下代码

import matplotlib.pyplot as plt

plt.scatter(a,b,c=distance1,marker='^',cmap='jet', lw=0,label='ab')

plt.scatter(c,d,c=distance2,marker='*',cmap='jet', lw=0,label='cd')

认为他的绘图绘制正确,colors 在第二次调用 plt.scatter 时分配不正确或被覆盖。 如何解决这个问题?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM