[R] Plotting numeric values against non numeric items

Jim Lemon jim at bitwrit.com.au
Sun Jan 10 11:57:09 CET 2010


On 01/10/2010 01:29 AM, lse1986 wrote:
> Hey Jim,
>
> Thanks for your reply!
>
> I tried what you said, i still kept getting errors.
>
> here's what i want my graph to look like:
>
> http://i.imagehost.org/0474/Untitled_5.jpg
>
>    
Oh, I see.

AandC<-data.frame('Not Stir'=c(686.36,398.32),Stir=c(179.17,60.29))
rownames(AandC)<-c("Cube","Granules")
AandC
x11(height=3)
layout(matrix(1:2,1,2),c(1,2),c(1,1))
par(mar=c(1,0,0,0))
plot(0,type="n",axes=FALSE,xlab="",ylab="")
par(xpd=TRUE)
text(1,0.5,"A and C",cex=1.5)
par(xpd=FALSE)
library(plotrix)
addtable2plot(1,0,AandC,xjust=0.5,yjust=0.5,bty="o",hlines=TRUE,
  display.rownames=TRUE,cex=0.8)
par(mar=c(2,5,4,6),las=1,xaxs="i",yaxs="i",tcl=-0.2)
matplot(t(AandC),xlim=c(0.7,2.3),ylim=c(0,800),type="n",
  main="Dissolving time vs stirring/not stirring\nfor sugar cubes and 
granules",
  ylab="Dissolving time (seconds)",cex=0.8,
  axes=FALSE)
fullaxis(1,at=c(0.7,1.5,2.3),labels=c("","",""))
mtext(c("Not stir","Stir"),1,at=1:2)
axis(2,at=seq(0,800,by=100),cex=0.8)
grid(nx=0,ny=8,lty=1)
matpoints(t(AandC),type="o",col=c(4,2),pch=c(18,15),lty=1,lwd=2)
par(xpd=TRUE)
legend(2.7,400,c("Cubes","Granules"),pch=c(18,15),col=c(4,2),
  bty="n",lwd=2,lty=1,xjust=0.5,yjust=0.5,cex=0.8)
rect(0.1,-130,3,1100)
par(xpd=FALSE)

Jim



More information about the R-help mailing list