美文网首页
2020-12-09 第三章图形初阶3.0

2020-12-09 第三章图形初阶3.0

作者: L6511 | 来源:发表于2020-12-09 16:02 被阅读0次
> 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)
Rplot02.png
> 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)
Rplot.png
image.png
image.png image.png

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

相关文章

网友评论

      本文标题:2020-12-09 第三章图形初阶3.0

      本文链接:https://www.haomeiwen.com/subject/akrhgktx.html