Ask Your Question
0

Plotting points with different colours

asked 2013-01-11 10:58:31 +0100

manolomartinez gravatar image

I'm trying to plot a number of points such that each has a colour that depends on a certain parameter. I have two lists, points and heights, and I would like to do something like this:

for i in range(len(points)):
    point2d(points[i], rgbcolor = (0,0, heights[i]))

This creates len(points) different graphics, so it's not what I want. What do I need to change?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2013-01-11 11:30:46 +0100

achrzesz gravatar image

updated 2013-01-11 11:41:45 +0100

Do you need something like:

sum([point((x,sin(x)),rgbcolor=hue(sin(x)),size=30) for x in srange(0,10,0.1)])
edit flag offensive delete link more

Comments

Yes! I would have never guessed `sum` does it. I guess I do not really understand what a point object is. For example, if I want to add a `polygon()` to the same plot, how do I do it?

manolomartinez gravatar imagemanolomartinez ( 2013-01-11 12:28:14 +0100 )edit
2

If p1 is any plot and p2 a polygon then do: p1+p2

achrzesz gravatar imageachrzesz ( 2013-01-11 12:48:31 +0100 )edit

OK, I see how it goes. Thanks again.

manolomartinez gravatar imagemanolomartinez ( 2013-01-11 13:02:29 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-11 10:58:31 +0100

Seen: 593 times

Last updated: Jan 11 '13