我需要画两组100点的图。 第一组点沿着Y轴移动,下一组点离第一组点稍远一些。在
我的代码如下:
import matplotlib.pyplot as plt
data= numpy.array(network) #network is a list of values
datatwo= numpy.array(list) #list is another list
cmap= numpy.array([(1,0,0),(0,1,0)])
uniqdata, idx=numpy.unique(data, return_inverse=True)
uniqdata, idx=numpy.unique(datatwo, return_inverse=True)
N=len(data)
M=len(datatwo)
fig, ax=plt.subplots()
plt.scatter(numpy.zeros(N), numpy.arange(1,N+1), s=50, c=cmap[idx])
plt.scatter(numpy.ones(M), numpy.arange(1,M+1), s=50, c=cmap[idx])
plt.grid()
plt.show()
我的问题是两个列表,network和list,有不同的值,但是解释器将同一组点绘制两次图形。我需要两组不同的点,一组分别用于网络和列表。在
密码怎么了? 谢谢
下面是一段代码,它将绘制2个列表中包含的唯一值,第一组沿着Y轴,第二组位于Y=1,每个列表使用不同的颜色。我猜,因为您使用的是
np.unique
,所以这两个列表包含了重复的值,您不想多次绘制这些值。在希望这有帮助
相关问题 更多 >
编程相关推荐