MPL colors

Dear ALL,

MPL accepts several formats for passing color information for the
plotting methods (plot, xlabel, ylabel, etc.) and these are well
documented. The set_color() and other methods in
matplotlib.Lines.Line2D accept all these formats, but I could not
figure out how to retrieve the current color of a plot using the
get_color() method in a format other than the 'b', 'r', 'g', etc.
predefined color symbols! I would instead like to be able to retrieve
the current color in RGB hex or HTML format. Is it possible?

Thanks in advance!

With best regards,

···

--
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: maurobio@...287...
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."

Yep, we have a color converter for that -- it recognizes any mpl color
string and returns rgba:

In [72]: from matplotlib.colors import colorConverter

In [73]: colorConverter.to_rgba('b')
Out[73]: (0.0, 0.0, 1.0, 1.0)

In [74]: colorConverter.to_rgba('blue')
Out[74]: (0.0, 0.0, 1.0, 1.0)

···

On Tue, Dec 9, 2008 at 1:01 PM, Mauro Cavalcanti <maurobio@...287...> wrote:

Dear ALL,

MPL accepts several formats for passing color information for the
plotting methods (plot, xlabel, ylabel, etc.) and these are well
documented. The set_color() and other methods in
matplotlib.Lines.Line2D accept all these formats, but I could not
figure out how to retrieve the current color of a plot using the
get_color() method in a format other than the 'b', 'r', 'g', etc.
predefined color symbols! I would instead like to be able to retrieve
the current color in RGB hex or HTML format. Is it possible?

Dear John,

Thanks, it works well!

Best regards,

2008/12/9 John Hunter <jdh2358@...287...>:

···

Yep, we have a color converter for that -- it recognizes any mpl color
string and returns rgba:

In [72]: from matplotlib.colors import colorConverter

In [73]: colorConverter.to_rgba('b')
Out[73]: (0.0, 0.0, 1.0, 1.0)

In [74]: colorConverter.to_rgba('blue')
Out[74]: (0.0, 0.0, 1.0, 1.0)

--
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: maurobio@...287...
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."