Re: [R] Rotated text on a regression line

2008-05-28 Thread Thomas Adams
Christoph, I see two problems: (1) use plot(x,y,pch=16,xlim=c(0,10),asp=1), as the default has the x/y scales different. (2) It looks to me that the expression srt=180/pi*atan(slope) should be srt=180*atan(slope)/pi Regards, Tom Dr. Christoph Scherber wrote: Dear all, I stumbled over a

[R] Rotated text on a regression line

2008-05-27 Thread Dr. Christoph Scherber
Dear all, I stumbled over a problem recently when trying to use srt with text() on a windows device. What I intended to do was to plot a simple regression line, and to rotate a piece of text such that the text has the same angle as the regression line. However, the text is always plotted in a

Re: [R] Rotated text on a regression line

2008-05-27 Thread Charilaos Skiadas
I think this comment for ?par, meant for both crt and srt, applies: crt A numerical value specifying (in degrees) how single characters should be rotated. It is unwise to expect values other than multiples of 90 to work. Compare with srt which does string rotation. So I would say that

Re: [R] Rotated text on a regression line

2008-05-27 Thread Xiaohui Chen
Note that the scale of x-axis and y-axis is different in your plot. One simple way to avoid this is to keep the data unit in the x direction is equal that in the y direction, by setting asp=1 in calling plot function. X Dr. Christoph Scherber 写道: Dear all, I stumbled over a problem recently

Re: [R] Rotated text on a regression line

2008-05-27 Thread Dr. Christoph Scherber
Thanks to all for the postings so far! I found that setting asp=0.5 and then dividing the slope by 2 seems to do the trick: ## x=1:10 y=x*2-rnorm(1:10) plot(x,y,pch=16,asp=0.5) abline(lm(y~x)) yval=predict(lm(y~x),list(x=rep(2,length(x[1] slope=as.numeric(lm(y~x)[[1]][2])

Re: [R] Rotated text on a regression line

2008-05-27 Thread Charles C. Berry
On Tue, 27 May 2008, Xiaohui Chen wrote: Note that the scale of x-axis and y-axis is different in your plot. One simple way to avoid this is to keep the data unit in the x direction is equal that in the y direction, by setting asp=1 in calling plot function. Or when that is not possible or