|
From: Adam H. <hug...@gm...> - 2014-03-05 20:07:53
|
Well, the hack wasn't as messy as I thought. Still feel like there's a
better way...
def show_colors_default():
fig, axfoo = plt.subplots()
clist = []
c = axfoo._get_lines.color_cycle.next()
# Iterate until duplicate is found
while c not in clist:
clist.append(c)
c = axfoo._get_lines.color_cycle.next()
# Reset colorcycle
for i in range(len(clist) -1):
axfoo._get_lines.color_cycle.next()
return clist
On Wed, Mar 5, 2014 at 2:56 PM, Adam Hughes <hug...@gm...> wrote:
> Hi,
>
> I am making a stacked histogram where one must enter the desired colors
> together in a list/array when the histogram is called. For certain objects
> in my code, it's helpful to assign a color to them, so that they are
> immediately identified across various plots. Therefore, I essentially want
> to take the color cycle, swap out a few entries for which colors have been
> assigned by the user, and otherwise keep the cycle in tact. For example,
> if the first object is to be orange, but no other colors are assigned, I
> want something like:
>
> colors= ['orange', default_cycle[1::]]
>
> However, according to some threads, the only way to access the color cycle
> that I'm aware of is through a generator stored in:
>
> axes._get_lines.color_cycle()
>
> I don't like this approach because iterating through the color cycle will
> cause the next plot to start at a different point in the cycle. I'm sure I
> can hack something up that gets around this, but there seems to be a
> canonical way to just list all of the default colors in a list once and be
> done with it. Is this the case?
>
> Thanks.
>
|