ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 11 Jan 2013 06:02:29 -0600Plotting points with different colourshttps://ask.sagemath.org/question/9701/plotting-points-with-different-colours/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?Fri, 11 Jan 2013 03:58:31 -0600https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/Answer by achrzesz for <p>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, <code>points</code> and <code>heights</code>, and I would like to do something like this:</p>
<pre><code>for i in range(len(points)):
point2d(points[i], rgbcolor = (0,0, heights[i]))
</code></pre>
<p>This creates <code>len(points)</code> different graphics, so it's not what I want. What do I need to change?</p>
https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?answer=14444#post-id-14444Do you need something like:
sum([point((x,sin(x)),rgbcolor=hue(sin(x)),size=30) for x in srange(0,10,0.1)])Fri, 11 Jan 2013 04:30:46 -0600https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?answer=14444#post-id-14444Comment by manolomartinez for <p>Do you need something like:</p>
<pre><code>sum([point((x,sin(x)),rgbcolor=hue(sin(x)),size=30) for x in srange(0,10,0.1)])
</code></pre>
https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18409#post-id-18409Yes! 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?Fri, 11 Jan 2013 05:28:14 -0600https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18409#post-id-18409Comment by achrzesz for <p>Do you need something like:</p>
<pre><code>sum([point((x,sin(x)),rgbcolor=hue(sin(x)),size=30) for x in srange(0,10,0.1)])
</code></pre>
https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18408#post-id-18408If p1 is any plot and p2 a polygon then do: p1+p2Fri, 11 Jan 2013 05:48:31 -0600https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18408#post-id-18408Comment by manolomartinez for <p>Do you need something like:</p>
<pre><code>sum([point((x,sin(x)),rgbcolor=hue(sin(x)),size=30) for x in srange(0,10,0.1)])
</code></pre>
https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18407#post-id-18407OK, I see how it goes. Thanks again.Fri, 11 Jan 2013 06:02:29 -0600https://ask.sagemath.org/question/9701/plotting-points-with-different-colours/?comment=18407#post-id-18407