import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
# def discrete_cmap() is omitted here...
# some sample data
x = np.linspace(0,10,11)
y = np.linspace(0,10,11)
z = x+y
# setup a Normalization instance
norm = colors.Normalize(z.min(),z.max())
# define the colormap
cmap = discrete_cmap(4, 'cubehelix')
# Use the norm and cmap to define the edge colours
edgecols = cmap(norm(z))
# Use that with the `edgecolors` argument. Set c='None' to turn off the facecolor
plt.scatter(x,y, edgecolors=edgecols, c = 'None', marker='o', s=40 )
plt.show()
可以使用
edgecolors
参数来分散你需要列一个颜色列表来输入
scatter
。我们可以使用您选择的colormap
和Normalizate
实例,将z
函数重缩放到0-1
范围我假设您的
discrete_cmap
函数类似于链接的here相关问题 更多 >
编程相关推荐