[AstroPy] matplotlib's pie colors

Jae-Joon Lee lee.j.joon@gmail....
Wed Nov 30 23:42:36 CST 2011


To improve the visibility of the text, you may use patheffect module,
instead of changing the coloring.

a = pie([1,2,4,3], labels=["1", "2", "4", "3"], autopct="%d")
from matplotlib.patheffects import withStrokeeffect_whiteborder =
withStroke(foreground="w", linewidth=3)
for txt in a[2]:    txt.set_path_effects([effect_whiteborder])
Regards,

-JJ



On Thu, Dec 1, 2011 at 10:38 AM, Derek Homeier
<derek@astro.physik.uni-goettingen.de> wrote:
> 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
>
> ax.set_color_cycle(pylab.cm.coolwarm(xrange(8,256,16)))
>
> and just pick your favourite from
> http://matplotlib.sourceforge.net/examples/pylab_examples/show_colormaps.html
>
> - 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.
>
> Cheers,
>                                                Derek
>
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy


More information about the AstroPy mailing list