choose line color with plot?

Hello:

I want to plot a variable number of lines but I would like the colors to
cycle through a set pattern defined by me.

I use this when working with line collections.

colors = [colorConverter.to_rgba(c) for c in
[('k','y','m','c','b','g','r')]

line = collections.LineCollection( ...
line.set_color(colors)

and it works great. But I need legends for each line so I can't use
collections. I would like to choose the colors and loop over a list if
the lines exceed the colors while using plot. Any ideas?

You can override the default color cycle:

import matplotlib.axes

matplotlib.axes._process_plot_var_args.defaultColors =
[k','y','m','c','b','g','r']

We should remove the leading underscore in the _process_plot_var_args
since it indicates users should not be working with it, but
customizing the color cycle is perfectly legit.

JDH

···

On Mon, May 19, 2008 at 8:38 AM, Zoho Vignochi <zoho.vignochi@...287...> wrote:

Hello:

I want to plot a variable number of lines but I would like the colors to
cycle through a set pattern defined by me.
...snip
and it works great. But I need legends for each line so I can't use
collections. I would like to choose the colors and loop over a list if
the lines exceed the colors while using plot. Any ideas?

John Hunter wrote:

···

On Mon, May 19, 2008 at 8:38 AM, Zoho Vignochi <zoho.vignochi@...287...> wrote:

Hello:

I want to plot a variable number of lines but I would like the colors to
cycle through a set pattern defined by me.
...snip
and it works great. But I need legends for each line so I can't use
collections. I would like to choose the colors and loop over a list if
the lines exceed the colors while using plot. Any ideas?

You can override the default color cycle:

import matplotlib.axes

matplotlib.axes._process_plot_var_args.defaultColors =
[k','y','m','c','b','g','r']

We should remove the leading underscore in the _process_plot_var_args
since it indicates users should not be working with it, but
customizing the color cycle is perfectly legit.

True, but from the standpoint of user interface design this may not be a good way to do it. At the very least, shouldn't there be a more concise variable or function? _process_plot_var_args really deserves its leading underscore. We could use something like an axes-level function, "set_color_cycle(clist)" to encapsulate what you suggest above.

Eric

I added a function and a method to control the color cycle. See examples/api/color_cycle.py, and r5250.

Eric

Eric Firing wrote:

···

John Hunter wrote:

On Mon, May 19, 2008 at 8:38 AM, Zoho Vignochi <zoho.vignochi@...287...> wrote:

Hello:

I want to plot a variable number of lines but I would like the colors to
cycle through a set pattern defined by me.
...snip
and it works great. But I need legends for each line so I can't use
collections. I would like to choose the colors and loop over a list if
the lines exceed the colors while using plot. Any ideas?

You can override the default color cycle:

import matplotlib.axes

matplotlib.axes._process_plot_var_args.defaultColors =
[k','y','m','c','b','g','r']

We should remove the leading underscore in the _process_plot_var_args
since it indicates users should not be working with it, but
customizing the color cycle is perfectly legit.

True, but from the standpoint of user interface design this may not be a good way to do it. At the very least, shouldn't there be a more concise variable or function? _process_plot_var_args really deserves its leading underscore. We could use something like an axes-level function, "set_color_cycle(clist)" to encapsulate what you suggest above.

Eric

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options