That's what ``scatter`` is intended for.

Basically, you want something like:

    plt.scatter(x, y, c=z, marker='s')
    plt.colorbar()

Note that you can also vary the markers by size based on an additional
parameter, as well.

Have a look at this example:
http://matplotlib.org/examples/pylab_examples/scatter_demo.html

Hope that helps,
-Joe


On Fri, Oct 19, 2012 at 2:19 PM, elmar werling <el...@net4werling.de> wrote:

> Hi,
>
> is there a way to adjust the marker color in a xy-plot in relation to
> the value of a third parameter. Something as the following - not working
> - example 1.
>
> Example 2 is working but rather slow for large arrays.
>
> cheers
> Elmar
>
>
>
>
> # example 1
>
> import matplotlib.pyplot as plt
>
> x = [1,2,3,4]
> y = x
> c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
>
> plt.plot(x,y, color=c, marker='s')
> plt.show()
>
>
> example 2:
>
> import matplotlib.pyplot as plt
>
> x = [1,2,3,4]
> y = x
> c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
>
> for i in range(len(x)):
>      plt.plot(x[i], y[i], color=c[i], marker='s')
>
> plt.show()
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to