Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Labeling points in ListPlot
Replies: 4   Last Post: Sep 8, 2005 5:10 AM

 Messages: [ Previous | Next ]
 David Annetts Posts: 269 Registered: 2/11/05
Re: Labeling points in ListPlot
Posted: Sep 5, 2005 2:35 AM

Hi Steve,
>
> I have a series of coordinates such as
> {{x1,y1},{x2,y2},...,{xn,yn}}, a few dozen at most. I want to
> put labels on the points such as p1, p2,...,pn, etc. in some
> desired typeface and size. I also need to control the small
> offset between the label and the dot representing the point.
> Does Epilog have anything to do with this? Help doesn't

You could use LabeledListPlot ....

Or, if you want to use Epilog, keep in mind that Text[] has an inbuilt
offset of the label from the point so you can have the label printed over,
under or around the coordinate.

For example, with
data = {#, Random[]} & /@ Range[10];

Apart from the obvious method of

Needs["Graphics`"]
LabeledListPlot[data];

You might produce a labelled plot using

txt = Text[#, data[[#]], {-1, 0}] & /@ Range[Length@data]
Show[Graphics[{AbsolutePointSize[5], Point[#] & /@ data}], Epilog ->
txt, Frame -> True];

Or

txt = Text[#, data[[#]], {1, 0}] & /@ Range[Length@data]
Show[Graphics[{AbsolutePointSize[5], Point[#] & /@ data}], Epilog ->
txt,Frame -> True];

Or even

off = If[# < 5, {-1, 0}, {1, 0}] & /@ Range[Length@data];
txt = Text[StringJoin["Point ", ToString[#]], data[[#]], off[[#]]] &
/@ Range[Length@data];
Show[Graphics[{AbsolutePointSize[5], Point[#] & /@ data}], Epilog ->
txt,Frame -> True];

There are other methods, but these will get you started.

Regards,

Dave.

Date Subject Author
9/4/05 Steve Gray
9/5/05 Bob Hanlon
9/5/05 AES
9/5/05 David Annetts
9/8/05 shizp@263.net