Highlight Points in a Plot

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Highlight Points in a Plot

SamT
Hi,

I have plotted a cdf using the ecdf function with plot().  I want to highlight/identify points on the same plot.  Also, because this is a cdf I am not sure of the y coords for the point, otherwise I thought of using highlight in the NCStats package.

Thanks  
Reply | Threaded
Open this post in threaded view
|

Re: Highlight Points in a Plot

David Winsemius

On May 3, 2010, at 12:28 PM, SamT wrote:

>
> Hi,
>
> I have plotted a cdf using the ecdf function with plot().

Code would make this concrete.

>  I want to
> highlight/identify points on the same plot.  Also, because this is a  
> cdf I
> am not sure of the y coords for the point, otherwise I thought of  
> using
> highlight in the NCStats package.

The y coordinate is just ecdf(object)(x.value)

... since ecdf returns a function, you get to use it as a function.  
Really
a beautiful tool. Thank you Martin Maechler.

>
> Thanks
> --
--

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: Highlight Points in a Plot

SamT
For simplicity we'll assume my code looks as follows

plot(ecdf(1:1000))

which produces a diagonal line.  

Ideally, I'd like to highlight or label in a different color certain X values (say 50,55,60,65)

Is there a function which will allow me to do this?
Reply | Threaded
Open this post in threaded view
|

Re: Highlight Points in a Plot

David Winsemius

On May 3, 2010, at 3:16 PM, SamT wrote:

>
> For simplicity we'll assume my code looks as follows
>
> plot(ecdf(1:1000))
>
> which produces a diagonal line.
>
> Ideally, I'd like to highlight or label in a different color certain X
> values (say 50,55,60,65)
>
> Is there a function which will allow me to do this?

Yes, ecdf() which returns a function

points(c(50,55,60,65), ecdf(1:1000)( c(50,55,60,65) ), col=c("red",  
"green", "yellow", "blue") )

Draws colored points.

Could also use text() with same coordinates provided by a  
"highlightvector" and ecdf(datavector)(highlightvector).

--
David.
> --
> View this message in context: http://r.789695.n4.nabble.com/Highlight-Points-in-a-Plot-tp2124224p2124469.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: Highlight Points in a Plot

SamT
Thanks David, the text() worked for me.  I wasnt able to correctly use plot with points and the ecdf function.

David Winsemius wrote
Yes, ecdf() which returns a function

points(c(50,55,60,65), ecdf(1:1000)( c(50,55,60,65) ), col=c("red",  
"green", "yellow", "blue") )

Draws colored points.

Could also use text() with same coordinates provided by a  
"highlightvector" and ecdf(datavector)(highlightvector).

--
David.
> --
> View this message in context: http://r.789695.n4.nabble.com/Highlight-Points-in-a-Plot-tp2124224p2124469.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org 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

______________________________________________
R-help@r-project.org 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.