[R] Add coordinates at specific points...

David Winsemius dwinsemius at comcast.net
Thu Jul 14 02:10:55 CEST 2011


On Jul 13, 2011, at 7:59 PM, JIA Pei wrote:

>
> Thanks David, for your prompt reply.
> Ok... just avoid this mess.
> I'd love to emphasize the key point M(2.1, sin(2.1)), and just write  
> a point coordinate by the side of M .How to do that easily?

Have you worked through the examples on the help(text) page? This does  
not seem to be that difficult. Three essential arguments.... x,y and  
text. You are supposed to put for effort and show what code you have  
tried.

text(2.1, sin(2.1), labels="M=(2.1, sin(2.1) )")

You can play around with the positioning arguments, which IIRC are  
adj= and <something else>.

> By the way, if there is another point N(2.2, sin(2.2)), will M and N  
> conflict (overlap) each other?

I don't see how that could be avoided. (Last color wins.) We don't  
have 3d glasses for our screens yet. Transparenct colors are  
available, but you don't seem to be ready for that yet.

>
> Cheers
> Pei
>
>
>
> On Wed, Jul 13, 2011 at 4:49 PM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>
> On Jul 13, 2011, at 7:42 PM, JIA Pei wrote:
>
>
>
>
> Hi, Thanks David Winsemius:
>
>
> "mtext" works !! However, in R plot, "mtext" will automatically  
> overlap/overwrite the existing coordinates, which makes the  
> coordinates a messy.
> Refer to http://www.visionopen.com/Rplot.png , which is produced by  
> only 3 lines.
>
> dev.new(width = 640, height = 480)
> plot(sin, -pi, 2*pi)
> mtext(text="2.1000", side = 1, line = 1,  at = 2.1)
>
> In order to avoid the coordinates overlap, can I change the position  
> of "2.1000" from outside the box to inside the box? If possible, how  
> to?
> I tried “outer = FALSE,” nothing special happened ever !!
>
> You should use text() rather than mtext() if you are going to plot  
> within the "user area".
>
>
>
>
> cheers
> Pei
>
>
>
> On Wed, Jul 13, 2011 at 1:41 PM, David Winsemius <dwinsemius at comcast.net 
> > wrote:
>
> On Jul 13, 2011, at 1:22 PM, JIA Pei wrote:
>
> Hi, all:
>
> I used two lines of very simple code to draw a sin curve.
>
> dev.new(width = 640, height = 480)
> plot(sin, -pi, 2*pi)
>
> First look at:
>
> ?mtext   # then try
> mtext(text="2.5000", side = 1, line = 1,  at = 2.5)
>
>
>
> Now, I added a specific line (red line in the picture at
> http://www.visionopen.com/Rplot.png) by using abline.
> However, I still love to add the X-coordinate "2.50000" outside the
> rectangle box. How to do it in R?
> Right now, I'm using Windows Paint to add the characters "2.50000"  
> up to the
> plot drawn by R.
>
>
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list