我觉得我在这里遗漏了一些非常明显的东西,但我无法在pylab中得到散点图以黑白打印.任何和所有的帮助将不胜感激.这是我的代码:
from pylab import *
from random import random
ioff()
r = range(10)
x = [3 + i + random() for i in r]
y = [50*i + random() for i in r]
x2 = [5 + i + random() for i in r]
y2 = [5*i + random() for i in r]
scatter(x,y, marker = 'o', hold = True, label = 'collected underwear',cmap=cm.Greys)
scatter(x2,y2, marker = 's', hold = True, label = 'Profit!',cmap=cm.Greys)
legend(loc='upper left')
show()
谢谢,
亚当
最佳答案 如果您只想随意指定颜色,请执行
color="k"
黑色,做
color="0.x"
对于灰度,x可以是任何数字,只要0.x在0和1之间.
但是,如果您希望标记颜色由另一个数组z确定,请执行
scatter(x,y,c=z, cmap=cm.Greys)
因此对于
from pylab import *
from random import random
r = range(10)
x = [3 + i + random() for i in r]
y = [50*i + random() for i in r]
x2 = [5 + i + random() for i in r]
y2 = [5*i + random() for i in r]
z2 = [i + random() for i in r]
scatter(x,y, c="0.1", marker = 'o', hold = True, label = 'collected underwear')
scatter(x2,y2, c=z2,marker = 's', hold = True, label = 'Profit!',cmap=cm.Greys)
legend(loc='upper left')
show()
你将会有