> dose<-c(20,30,40,45,60)
> drugA<-c(16,20,27,40,60)
> drugB<-c(15,18,25,31,40)
> opar<-par(no.readonly=TRUE)
> par(lwd=2,cex=1.5,font.lab=2)
> plot(dose,drugA,type="b",
+ pch=15,lty=1,col="red",ylim=c(0,60),
+ main="Drug A vs.Drug B",
+ xlab="Drug Dosage",ylab="Drug Response")
> lines(dose,drugB,type="b",
+ pch=17,lty=2,col="blue")
> abline(h=c(30),lwd=1.5,lty=2,col="gray")
> library(Hmisc)
> minor.tick(nx=3,ny=3,tick.ratio=0.5)
> legend("topleft",inset=.05,title="Drug Type",c("A","B"),
+ lty=c(1,2),pch=c(15,17),col=c("red","blue"))
>par(opar)

> attach(mtcars)
The following objects are masked from mtcars (pos = 3):
am, carb, cyl, disp, drat, gear, hp, mpg, qsec, vs, wt
The following object is masked from package:ggplot2:
mpg
> plot(wt,mpg,)
>
>
>
> plot(wt,mpg,
+ main="Mileage vs. Car Weight",
+ xlab="Weight",ylab="Mileage",
+ pch=18,col="blue")
> text(wt,mpg,
+ row.names(mtcars),
+ cex=0.6,pos=4,col="red")
> detach(mtcars)

> opar<-par(no.readonly=TRUE)
> par(cex=1.5)
> plot(1:7,1:7,type="n")
> text(3,3,"Example of default text")
> text(4,4,family="mono","Example of mono-spaced text")
> text(5,5,family="serif","Example of serif text")
> par(opar)




图形布局
详见87页
各个布局的范围值怎么协调
网友评论