# [R] Plotting Help

Jim Lemon jim at bitwrit.com.au
Sun May 9 07:49:29 CEST 2010

```On 05/09/2010 07:10 AM, Ravi Ramaswamy wrote:
> Hi - Wondering if someone could help me with a plotting problem.  I looked
> through the postings for this error message but the explanations are hard to
> follow.
>
> Basically I have matrix of 80 rows and 101 columns.  I would like to
> generated a line graph that has 80 plots, one for each row, with the first
> number in that row equal to y (response) and the remaining numbers equal to
> the Xs.
>
> Response numbers are between 0 and 100 (percentages) and Xs are all between
> 1 and 3.  Could someone tell me how to do it, and avoid the error message
> below?
>
Hi Ravi,
You can do it like this, but the example produces an awful mess.

rrdf<-data.frame(y=sample(0:100,80),
matrix(runif(8000)*1.99+1,nrow=80))
par(mar=c(5,4,4,4))
plot(0,xlim=c(1,101),ylim=c(0,100),type="n",xaxt="n",yaxt="n",
xlab="Y and X",ylab="Y value",main="Test plot")
axis(1,at=c(1,seq(11,101,by=10)),labels=c("Y",paste("X",seq(10,100,by=10),sep="")))
axis(2,col="red")
axis(4,at=c(0,50,100),labels=1:3,col="green")
mtext("X value",side=4,line=2,col="green")
for(dfrow in 1:80) {
points(1,rrdf[dfrow,1],col="red")
lines(2:101,(rrdf[dfrow,2:101]-1)*50,col="green")
}

Jim

```