我正在学习使用matplotlib绘制散点图。但是,有一个错误,它似乎与颜色参数有关。任何人都可以解释我的错误吗?我用谷歌搜索,但没有找到答案。提前谢谢。
xActA = range(10)
yActA = np.random.randn(10)
xActQ = range(10)
yActQ = np.random.randn(10)
xRa = np.random.randn(10)
yRa = np.random.randn(10)
f1 = figure(1)
scatter(xActA, yActA, c ='b', marker = 'o', facecolors = True, label = 'Answers')
scatter(xActQ, yActQ, c ='r', marker = 'o', facecolors = True, label = 'Questions')
xscale('log')
yscale('log')
title('User activity')
xlabel('Number of posts')
ylabel('Number of users')
legend()
f1.show()
f1.savefig('figure7_test.png')
答案 0 :(得分:1)
你给facecolors一个布尔值 该参数定义为:
facecolor or facecolors: matplotlib color arg or sequence of rgba tuples
只需制作facecolor = None
即可。你可能不想要这个,因为你得到两个图的相同颜色。如果消除参数,您将获得自动颜色。如果你仍然需要自定义颜色,最简单的方法是将它们指示为matplotlib颜色('黄色,'红色'等)
答案 1 :(得分:0)
听起来你应该为facecolors
参数提供一系列颜色值,而不是True
。