MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Labeling points in ListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60164] Re: [mg60145] Labeling points in ListPlot
  • From: "David Annetts" <davidannetts at aapt.net.au>
  • Date: Mon, 5 Sep 2005 02:27:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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.


  • Prev by Date: Re: Labeling points in ListPlot
  • Next by Date: Re: Re: ComplexExpand confusion
  • Previous by thread: Re: Labeling points in ListPlot
  • Next by thread: Re: Labeling points in ListPlot