Re: [R] R:plot and dots

From: Marc Schwartz (via MN) <>
Date: Fri 22 Jul 2005 - 01:38:21 EST

On Thu, 2005-07-21 at 16:18 +0200, Clark Allan wrote:
> hi all
> a very simple question.
> i have plot(x,y)
> but i would like to add in on the plot the observation number associated
> with each point.
> how can this be done?
> /
> allan

If you mean the unique observation number associated with each x,y pair, you can use:

  text(x, y, labels = ObsNumberVector, pos = 3)

after the plot(x, y) call:

 df <- data.frame(x = rnorm(10), y = rnorm(10), ID = 1:10)  with(df, plot(x, y))
 with(df, text(x, y, labels = ID, pos = 3))

See ?text for more information. Note that I used pos = 3 which places the label above the data point. There are other positioning parameters available, which are noted in the help file.

Note also that you might have to adjust the plot axis limits depending upon where you place the text and your extreme points.

If you mean the frequency of each x,y pair (if there is more than one observation per x,y pair), you might want to review Deepayan's recent post here:

HTH, Marc Schwartz mailing list PLEASE do read the posting guide! Received on Fri Jul 22 02:13:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:55 EST