[AstroPy] matplotlib's pie colors

Derek Homeier derek@astro.physik.uni-goettingen...
Wed Nov 30 19:38:02 CST 2011

On 01.12.2011, at 1:16AM, Grigoris Maravelias wrote:

> Thanks Jake, but I know that I can set the colors but I would like it to 
> happen without me specifying the colors like this. Another approach 
> would be to create a list of colors according to the objects 
> automatically somehow by using #hex codes but it is getting too much 
> without really a purpose.
> Thanks for you answer!
> Grigoris
> On 11/30/2011 06:26 PM, Jacob VanderPlas wrote:
>> Try the following:
>>>>> ax = pylab.axes()
>>>>> ax.set_color_cycle(['green', 'orange', 'blue', 'red','brown','pink'])
>>>>> ax.plot(x1, y1)
>>>>> ax.plot(x2, y2)
Thanks everyone, that's a very useful pointer - I have been wondering as well how 
to best set the default sequence of colours. 
Constructing a sequence is actually not that different using the *range() functions; 
e.g. you could apply them on rgb tuples, or even more comfortable, directly access 
any of the default colourmaps like 


and just pick your favourite from 

- now there'd only have to be a wider choice of maps that would all print well as 
lines on white bg ;-) but for pie charts etc. a lot of them should work well.


More information about the AstroPy mailing list