Set the color of a plot in argument's function

I don't manage to put the color of my plot in the argument' list function.

Example:

def function(color):

      plot(x,y,'.', color, label = "this is my curve")

function('r')

even if I put function(" 'r' ") it doesn't work.

Any idea?

I would suggest using named arguments for everything other than x and y, so

plot(x,y,marker=',', color=color, label='this is my curve')

http://matplotlib.sourceforge.net/api/axes_api.html?highlight=plot#matplotlib.axes.Axes.plot

daryl

···

On Thu, Feb 2, 2012 at 8:52 AM, Fabien Lafont <lafont.fabien@...287...> wrote:

I don't manage to put the color of my plot in the argument' list function.

Example:

def function(color):

 plot\(x,y,&#39;\.&#39;, color, label = &quot;this is my curve&quot;\)

function('r')

even if I put function(" 'r' ") it doesn't work.

Any idea?

Thanks Daryl, it works!

2012/2/2 Daryl Herzmann <akrherz@...667...>:

···

On Thu, Feb 2, 2012 at 8:52 AM, Fabien Lafont <lafont.fabien@...287...> wrote:

I don't manage to put the color of my plot in the argument' list function.

Example:

def function(color):

 plot\(x,y,&#39;\.&#39;, color, label = &quot;this is my curve&quot;\)

function('r')

even if I put function(" 'r' ") it doesn't work.

Any idea?

I would suggest using named arguments for everything other than x and y, so

plot(x,y,marker=',', color=color, label='this is my curve')

http://matplotlib.sourceforge.net/api/axes_api.html?highlight=plot#matplotlib.axes.Axes.plot

daryl