1

In Matplotlib, I have several sets of points to fill in with different colours, one per set. Now, the number of sets varies, so I would like to make sure that that the same colour doesn't appear more than once in the same plot.

Right now I just do:

colors = itertools.cycle(['r','g','b','c','y','m'])
# ...
ax.plot(Xs_for_a_set, Ys_for_a_set, c=colors.next())

... but I am limited to that number of colors. From the documentation I don't get how to specify a random color in RGB...

4

1 回答 1

1

您可以将颜色指定为字符串中的十六进制值。

color = '#eeefff'

使用它,您基本上可以通过 RGB 访问所有颜色,并且可以根据需要创建任意数量的颜色

于 2013-07-05T13:51:17.967 回答