ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Jul 2015 16:02:25 +0200Label each pointhttps://ask.sagemath.org/question/28615/label-each-point/ Is it possible in Sage to label each point in a 2-D plot? I'd like to create something like this:
![image description](https://dl.dropboxusercontent.com/u/22824199/forums/sagemath/labeled%20points.PNG)
Sun, 19 Jul 2015 08:04:48 +0200https://ask.sagemath.org/question/28615/label-each-point/Answer by ndomes for <p>Is it possible in Sage to label each point in a 2-D plot? I'd like to create something like this:
<img alt="image description" src="https://dl.dropboxusercontent.com/u/22824199/forums/sagemath/labeled%20points.PNG"/></p>
https://ask.sagemath.org/question/28615/label-each-point/?answer=28649#post-id-28649 f(x) = (x-2)^2-9
P = [(x0,f(x0)) for x0 in [-2..6]]
G = plot(f,-2,6)
G += points(P)
for p in P:
G += text(' (%s,%s)'%(p[0],p[1]),p,horizontal_alignment='left',color='red')
G.show() Sun, 19 Jul 2015 22:30:25 +0200https://ask.sagemath.org/question/28615/label-each-point/?answer=28649#post-id-28649Comment by mellow_yellow for <pre><code>f(x) = (x-2)^2-9
P = [(x0,f(x0)) for x0 in [-2..6]]
G = plot(f,-2,6)
G += points(P)
for p in P:
G += text(' (%s,%s)'%(p[0],p[1]),p,horizontal_alignment='left',color='red')
G.show()
</code></pre>
https://ask.sagemath.org/question/28615/label-each-point/?comment=28654#post-id-28654very nice! thank you!Mon, 20 Jul 2015 16:02:25 +0200https://ask.sagemath.org/question/28615/label-each-point/?comment=28654#post-id-28654