color argument to collections

Eric - If you are going to make changes here, would it be

    > possible to pass a sequence of colors, one for each line
    > segment in the collection. You can check, for example,
    > whether the length of the sequence is equal to the number of
    > segments. Would be very helpful for some people, as I have
    > seen requests for this possibility several times on the
    > list.

Unless, I am misunderstanding you, you can already do that. For
example, this is what scatter and polor do to make each element of the
collection a different color.

Eric is talking about a convenience function so that you can pass
arbitrary colors arguments rather than rgba, ie the equivalent of

  from matplotlib.colors import colorConverter
  colors = [colorConverter.to_rgba(x) for x in 'yellow', 0.5, (1,0,0,0.5)]

you can then pass colors to a collection with three elements and get
the three colors yellow, gray and transparent red

JDH

John Hunter wrote:

"Mark" == Mark Bakker <markbak@...149...> writes:

    > Eric - If you are going to make changes here, would it be
    > possible to pass a sequence of colors, one for each line
    > segment in the collection. You can check, for example,
    > whether the length of the sequence is equal to the number of
    > segments. Would be very helpful for some people, as I have
    > seen requests for this possibility several times on the
    > list.

Unless, I am misunderstanding you, you can already do that. For
example, this is what scatter and polor do to make each element of the
collection a different color.

Eric is talking about a convenience function so that you can pass
arbitrary colors arguments rather than rgba, ie the equivalent of

  from matplotlib.colors import colorConverter
  colors = [colorConverter.to_rgba(x) for x in 'yellow', 0.5, (1,0,0,0.5)]

you can then pass colors to a collection with three elements and get
the three colors yellow, gray and transparent red

Exactly. The convenience function already exists--it is Collection._get_color()--and it is already used in all the set_facecolor() and similar methods, but not in processing the initializer argument list. What I have in mind is simply using it at initialization time. I have not thought it through carefully yet, though; it is just something that came up while working on a new colorbar, and for the moment I am concentrating on the latter.

Eric

Oops, no idea this was already implemented.
I recalled discussion about the topic from way back I guess.
I’ll give it a shot.
To get back to the real topic: it would indeed be even nicer if we didn’t

have to convert to rgba.

···

On 5/10/06, Eric Firing <efiring@…229…> wrote:

John Hunter wrote:

“Mark” == Mark Bakker <markbak@…149…> writes:

> Eric - If you are going to make changes here, would it be
> possible to pass a sequence of colors, one for each line
> segment in the collection.  You can check, for example,
> whether the length of the sequence is equal to the number of
> segments.  Would be very helpful for some people, as I have
> seen requests for this possibility several times on the
> list.

Unless, I am misunderstanding you, you can already do that. For

example, this is what scatter and polor do to make each element of the
collection a different color.

Eric is talking about a convenience function so that you can pass
arbitrary colors arguments rather than rgba, ie the equivalent of

from matplotlib.colors import colorConverter
colors = [colorConverter.to_rgba(x) for x in ‘yellow’, 0.5, (1,0,0,0.5)]

you can then pass colors to a collection with three elements and get

the three colors yellow, gray and transparent red

Exactly. The convenience function already exists–it is
Collection._get_color()–and it is already used in all the
set_facecolor() and similar methods, but not in processing the

initializer argument list. What I have in mind is simply using it at
initialization time. I have not thought it through carefully yet,
though; it is just something that came up while working on a new
colorbar, and for the moment I am concentrating on the latter.

Eric