欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

【R】语言第五课----画图

发布时间:2023/12/20 38 豆豆
生活随笔 收集整理的这篇文章主要介绍了 【R】语言第五课----画图 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
?plot#高级绘图函数 可以完整地绘制出一张图 ?mtcars plot(mtcars$wt) plot(mtcars[,1:2]) plot(mtcars) plot(mtcars$wt,mtcars$disp) plot(mtcars$wt,mtcars$disp,type='p') plot(mtcars$wt,mtcars$disp,type='l') plot(mtcars$wt,mtcars$disp,type='b') plot(mtcars$wt,mtcars$disp,type='o')mtcars<-mtcars[order(mtcars$wt),] plot(mtcars$wt,mtcars$disp,type='o') plot(mtcars$wt,mtcars$disp,type='h')par(no.readonly = T) opar<-par(no.readonly = T) par(mfrow=c(3,3)) for (i in c('p','l','b','c','o','h','s','S','n')) {plot(mtcars$wt,mtcars$disp,type=i,main=paste('type',i)) } #s 和 S 都是阶梯线 n是空图par(opar) ?pch#pch plot(mtcars$wt,mtcars$disp,pch=2) plot(mtcars$wt,mtcars$disp,pch=2,cex=3)#折线图 lty lwd plot(mtcars$wt,mtcars$disp,type='l') plot(mtcars$wt,mtcars$disp,type='l',lty=3) plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3)#col plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col='blue') plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col=8)#col 从1到8,超过1-8还是重复1-8的颜色 plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col=4) plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col=12) plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col='#0000FF') plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col=rgb(0,0,1)) plot(mtcars$wt,mtcars$disp,type='l',lty=3,lwd=3,col=hsv(h=240/360,s=1,v=1))#饱和度#xlim ylim plot(mtcars$wt,mtcars$disp,xlim = c(2,4),ylim = c(100,400))#文本 plot(mtcars$wt,mtcars$disp,xlim = c(2,4),ylim = c(100,400),main = 'Motor Trend Car Road Tests',sub = '2019-6',xlab='wt',ylab = 'dist') plot(mtcars$wt,mtcars$disp,xlim = c(2,4),ylim = c(100,400),main = 'Motor Trend Car Road Tests',sub = '2019-6',ann = F)#ann=F表示去掉标签标题副标题 title(main = 'Motor Trend Car ...',sub = '2019-6',xlab='wt',ylab = 'dist')#低级绘图函数 再加上标签标题副标题#homework Q1 plot(mtcars$mpg,mtcars$qsec)#homework Q2 opar<-par(no.readonly = T) par(mfrow=c(4,4)) for (i in c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)) {plot(mtcars$mpg,mtcars$qsec,pch=i,main=paste('pch:',i)) } par(opar)#homework Q3 library(readxl) stock <- read_excel("D:/ChromeCoreDownloads/作业5/stock.xlsx") View(stock)#homework Q4 plot(stock$date,stock$investor_confidence_index,type = 'l',main = '投资者信心指数时序图',xlab = '时间',ylab = '投资者信心指数')

 


总结

以上是生活随笔为你收集整理的【R】语言第五课----画图的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。