[R] r-plot

Jim Lemon jim at bitwrit.com.au
Wed May 27 13:29:20 CEST 2009


durden10 wrote:
> Dear R-community
>
> I have a grueling problem which appears to be impossible to solve:
> I want to make a simple plot, here is my code: http://gist.github.com/118550
> Unfortunately, the annotation of both the x- and y-axis are not correct, as
> you can see in the following picture: 
> http://www.nabble.com/file/p23739356/plot.png 
> I am not an expert of R, so maybe someone can point me to the solution of
> this problem, i.e. both of the axes should start and end at the min / max
> values of the two vectors.
>
>   
Hi Durden,
This example seems to work for me. Is it just the X and Y axis labels 
that you want?

data_corr<-data.frame(
 Win=c(-0.08,-0.07,-0.01,-0.01,0.03,0.08,0.1,0.13,
  0.18,0.19,0.195,0.2,0.28,0.3,0.4),
 Calgary=c(11,7,5,4,3,8,6,7,3,2,1,8,0,1,3)
)
par(tcl=0.35,xaxs="r") # Switch tick marks to insides of axes
plot(data_corr, type = "p", xlab="VS signal change",
 ylab="Depression scale",axes=FALSE, col = "blue", lwd = 2)
#y-axis
axis(2, tcl=0.35,at=0:11)
#x-axis
test2<-seq(0,0.4,by=0.1)
axis(1, tcl=0.35,at=test2)
box()
abline(lm(data_corr[,2]~data_corr[,1]))

Jim




More information about the R-help mailing list