Matplotlib colors

I want to:
1. Have matplotlib assign the linecolor for a plot
2. Read the linecolor with .get_color()
3. Create another plot with the linecolor set to a lighter version of
the previous linecolor.

Ie:

a, = plot(x,y)
a.get_color() = 'b'
b, = plot(x,y, color = "#xxxxxx")

Since I'm only using the standard matplotlib assigned colors which
cycle through b,g,r,c,m,y,k I thought I would just create a mapping
between each color and a lighter version.

How do I get the hex or RGB string for the base matplotlib colors?

Also, if there's a different property I can use to lighten the line
color without changing the color that would be cool too.

Cheers,

Jonno.

I want to:

  1. Have matplotlib assign the linecolor for a plot

  2. Read the linecolor with .get_color()

  3. Create another plot with the linecolor set to a lighter version of

the previous linecolor.

Ie:

a, = plot(x,y)

a.get_color() = ‘b’

b, = plot(x,y, color = “#xxxxxx”)

Since I’m only using the standard matplotlib assigned colors which

cycle through b,g,r,c,m,y,k I thought I would just create a mapping

between each color and a lighter version.

How do I get the hex or RGB string for the base matplotlib colors?

There may be an easier way, but in the past I’ve used a color converter object

(which seems unnecessarily verbose):

import matplotlib.colors as mcolors
cc = mcolors.ColorConverter()
cc.to_rgb(‘b’)
(0, 0, 1)

Also, if there’s a different property I can use to lighten the line

color without changing the color that would be cool too.

If you have a white background (and no overlapping markers/lines), you could just set the “alpha” argument in the plot command.

Best,
-Tony

···

On Wed, Nov 16, 2011 at 5:35 PM, Jonno <jonnojohnson@…287…> wrote: