 # automatically plotting points in different colors

hi all,

i have a set of about 100-500 points that i’d like to color in different colors. i tried the following, using the c= argument to the scatter command:

x = rand(200)
scatter(x, x, c=xrange(1,201))

however, only a handful of colors seem to be used and the points look very similar. what i am looking for is a different color for every point – it can even be different shades, as in this example:

http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html

does anyone know how to create this?

also, more complex, is there a way to do this where every point gets not only a different color but a different symbol? e.g. ‘^’, ‘s’, ‘x’, etc. ? i know there aren’t 200 different symbols but it’d be nice if it cycled through the different symbols as much as possible (e.g. one point might be blue ‘^’ and another might be red ‘^’) to distinguish the points

thanks.

hi all,

i have a set of about 100-500 points that i’d like to color in different colors. i tried the following, using the c= argument to the scatter command:

x = rand(200)
scatter(x, x, c=xrange(1,201))

however, only a handful of colors seem to be used and the points look very similar. what i am looking for is a different color for every point – it can even be different shades, as in this example:

http://matplotlib.sourceforge.net/examples/pylab_examples/ellipse_collection.html

does anyone know how to create this?

The following works for me

In : x, y = np.random.rand(2, 100)

In : c = np.random.rand(100)

In : scatter(x, y, c=c)

Out: <matplotlib.collections.RegularPolyCollection object at 0x905e3ec>

also, more complex, is there a way to do this where every point gets not only a different color but a different symbol? e.g. ‘^’, ‘s’, ‘x’, etc. ? i know there aren’t 200 different symbols but it’d be nice if it cycled through the different symbols as much as possible (e.g. one point might be blue ‘^’ and another might be red ‘^’) to distinguish the points

This isn’t supported with scatter – you could make multiple calls to scatter or plot if you want different symbols, but if you need every symbol to be different this would be slow. In that case, you might want to write your own matplotlib.collections.PolygonCollection.

JDH

···

On Sat, Mar 14, 2009 at 12:22 PM, per freem <perfreem@…878…287…> wrote: