plot(cars$dist~cars$speed,#y~x,cars是R自带的数据main="Relationship between car distance & speed",#标题xlab = "Speed(miles per hour)",#x轴标题ylab = "Distance travelled (miles)",#Y轴标题xlim = c(0,30),#设置x轴的取值区间为0到30ylim = c(0,140),#设置y轴的取值区间为0到140xaxs = "i",#这里是设置x轴的风格,暂时没看明白有多大区别yaxs = "i",col = "red",#设置颜色pch = 19)#pch指代点的形状,用数字表示,可查看帮助文档#如果要保存图片怎么办呢?我觉得最简单的方法就是使用RStudio这个IDE,极其得好,可惜很多人都不知道。#如果你不会,可以用如下代码实现:#(图形的参数还有很多个,我这里只使用了其中的几个)png(filename="散点图.png",width=480,height=480)plot(cars$dist~cars$speed,#y~xmain="Relationship between car distance & speed",#标题xlab = "Speed(miles per hour)",#x轴标题ylab = "Distance travelled (miles)",#Y轴标题xlim = c(0,30),#设置x轴的取值区间为0到30ylim = c(0,140),#设置y轴的取值区间为0到140xaxs = "i",#这里是设置x轴的风格,暂时没看明白有多大区别yaxs = "i",col = "red",pch = 19)#pch指代点的形状,用数字表示,可查看帮助文档dev.off()
如果觉得《R语言绘制散点图》对你有帮助,请点赞、收藏,并留下你的观点哦!