How to label specific points on a scatterplot

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to label specific points on a scatterplot

rstudent
Command I am using for the plot:

plot(Raw[][Plate==101]~well[][Plate==101], xlab="Well", ylab="Raw", main="Plate 101")

I only want to label points on the graph where well equals B13, G13, K14 and N14 with the name of the well.

Thank you for your help.
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

David Winsemius

On Jul 8, 2011, at 1:31 PM, rstudent wrote:

> Command I am using for the plot:
>
> plot(Raw[][Plate==101]~well[][Plate==101], xlab="Well", ylab="Raw",
> main="Plate 101")
>
> I only want to label points on the graph where well equals B13, G13,  
> K14 and
> N14 with the name of the well.

?"%in%"
?text


>
> Thank you for your help.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-label-specific-points-on-a-scatterplot-tp3654697p3654697.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

rstudent
I can use the text() command to label all points but how do you specify only to label those four specific points on the graph?
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

David Winsemius

On Jul 8, 2011, at 2:02 PM, rstudent wrote:

> I can use the text() command to label all points but how do you  
> specify only
> to label those four specific points on the graph?
>

No context, no example, evidence that you read the rest of my message,  
no further response.

> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-label-specific-points-on-a-scatterplot-tp3654697p3654777.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

rstudent
I have only been using R for a very short time and I'm trying to learn.

What information do you need to help me?
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

VictorDelgado
In reply to this post by rstudent
rstudent,

one solution could be given by spliting your graph in two parts:

part_1 <- # take the desired four points subset #
part_2 <- # all rest points not to label

You will also need one vector with your names. I supose:

list <- c("B13", "G13", "K14", "N14")

So

plot(part_1$x, part_1$y)
text(part_1$x, part_1$y+.1, list)
points(part_2$x, part_2$y)

Maybe you will have to set the limits (xlim and ylim) of your graph and chage .1 to a more precise value.
Please, take care and ensure carefully reading of command internal help (typing ?text, for example), the R's help-pages are very clear and didactic.

Be sure also, searching for previous questions already made in "r-help", preventing double questions on basic isues, and be more specific possible about your problem. If your data is from base, I could give you one better answer.

Take care, Have a god job!

Victor Delgado
cedeplar.ufmg.br P.H.D. student
www.fjp.mg.gov.br reseacher
Victor Delgado Professor in department of Economics, UFOP - Univ. Federal de Ouro Preto, Brazil
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

David Winsemius
In reply to this post by rstudent

On Jul 8, 2011, at 2:53 PM, rstudent wrote:

> I have only been using R for a very short time and I'm trying to  
> learn.
>
> What information do you need to help me?

As it says at the bottom of every message to Rhelp:

" read the posting guide http://www.R-project.org/posting-guide.html "

>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-label-specific-points-on-a-scatterplot-tp3654697p3654903.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How to label specific points on a scatterplot

nmarshall
This post has NOT been accepted by the mailing list yet.
I am a little confused on how to do this as well.

Here is my data:
  Abundance Prevelance Intensity
1         25          6  2.666667
2        632        404 14.108911
3         46         33 11.878788
4          8          1  1.000000
5          9          3  5.666667
6          3          2  1.500000
7          7          1  1.000000
8        356         49  7.306122
9         17          7  4.571429
10        34          5  1.600000
11         3          1  2.000000
12        19          1  1.000000
13         1          1  1.000000
14        36          3  1.000000
15        39          4  2.750000
16        41          9  1.888889
17       147         25  4.360000
18        15          5  1.400000
19        11          2  1.000000
20        12          3  1.333333
21         5          1  1.000000
22        31         11  3.000000
23         4          1  1.000000

And then I created a 3d scatterplot.
> scatterplot3d(data)

I would like to label just points 2, 3, 8, and 17 as they stand out from the pack.  However, I would like to label them not as numbers but as the name of the data point.  So I assume this will be a two step process to complete this task, but I am not sure how to do it

If anyone could help me that would be great!