R基础绘图学习笔记(二)
来源:互联网 发布:mac 切换python版本 编辑:程序博客网 时间:2024/05/19 04:03
一些调整
1.一“筐“多图
par(mfrow=c(2,3))plot(rnorm(100),col="blue",main="Plot No.1")plot(rnorm(100),col="blue",main="Plot No.2")plot(rnorm(100),col="green",main="Plot No.3")plot(rnorm(100),col="black",main="Plot No.4")plot(rnorm(100),col="green",main="Plot No.5")plot(rnorm(100),col="orange",main="Plot No.6")par(mfcol=c(3,2))plot(rnorm(100),col="blue",main="Plot No.1")plot(rnorm(100),col="blue",main="Plot No.2")plot(rnorm(100),col="green",main="Plot No.3")plot(rnorm(100),col="black",main="Plot No.4")plot(rnorm(100),col="green",main="Plot No.5")plot(rnorm(100),col="orange",main="Plot No.6")par(mfrow=c(3,1))plot(market$revenue~as.Date(market$date,"%d/%m/%y"),type="l", #Specify type of plot as l for linemain="Revenue",xlab="Date",ylab="US Dollars",col="blue")plot(market$profits~as.Date(market$date,"%d/%m/%y"),type="l", #Specify type of plot as l for linemain="Profits",xlab="Date",ylab="US Dollars",col="red")plot(market$customers~as.Date(market$date,"%d/%m/%y"),type="l", #Specify type of plot as l for linemain="Customer visits",xlab="Date",ylab="Number of people",col="black")
2.修改坐标轴范围
xlim,ylim设定。
plot(cars$dist~cars$speed, xlim=c(30,0), ylim=c(0,150), xaxs="i", yaxs="i")plot(cars$dist~cars$speed, xlim=c(25,0), ylim=c(0,100), xaxs="i", yaxs="i")
3.添加图例
plot(rain$Tokyo,type="l",col="red", ylim=c(0,300), main="Monthly Rainfall in major cities", xlab="Month of Year", ylab="Rainfall (mm)", lwd=2)lines(rain$NewYork,type="l",col="blue",lwd=2)lines(rain$London,type="l",col="green",lwd=2)lines(rain$Berlin,type="l",col="orange",lwd=2) legend("topright", legend=c("Tokyo","New York","London","Berlin"), col=c("red","blue","green","orange"), lty=1,lwd=2)plot(rain$Tokyo,type="l",col="red", ylim=c(0,250), main="Monthly Rainfall in major cities", xlab="Month of Year", ylab="Rainfall (mm)", lwd=2)lines(rain$NewYork,type="l",col="blue",lwd=2)lines(rain$London,type="l",col="green",lwd=2)lines(rain$Berlin,type="l",col="orange",lwd=2)legend("top", legend=c("Tokyo","New York","London","Berlin"), ncol=4, cex=0.8, bty="n", col=c("red","blue","green","orange"), lty=1,lwd=2)
阅读全文
0 0
- R基础绘图学习笔记(二)
- R基础绘图学习笔记(一)
- R笔记(绘图)
- R软件学习笔记-5(R语言绘图)
- R语言绘图学习笔记
- 绘图与动画学习笔记(二)
- 从零开始系列-R语言基础学习笔记之二 数据结构(二)
- R语言学习笔记-绘图相关
- R语言学习笔记(3):绘图
- R语言学习笔记之绘图篇
- R语言学习笔记(二)
- R语言学习笔记(二)
- R语言学习笔记(二)
- R语言学习笔记(二)
- R语言学习笔记(二)
- R语言学习笔记——R语言绘图
- 从零开始系列-R语言基础学习笔记之二 数据结构(一)
- R语言绘图篇(二)
- 顶级论文详解-深度学习Faster R-CNN
- git 的简单使用
- 笔试题
- java内存泄漏问题
- 快排改进 解决升序第一个是最大数 降序第一个是最小数问题
- R基础绘图学习笔记(二)
- ApacheHttpServer修改httpd.conf配置文件
- deeplearing4J
- Dell 12G服务器 手动安装RedHat 6.X
- Map集合遍历方法
- 如何写一个死锁的java程序
- 反编译
- 针对回归问题的广义线性模型
- MySQL 基础 —— 数据类型、各种变量