Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David Annetts

Posts: 269
Registered: 2/11/05
Re: Labeling points in ListPlot
Posted: Sep 5, 2005 2:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
> say much about it.


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.




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.