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到30
ylim = c(0,140),#设置y轴的取值区间为0到140
xaxs = "i",#这里是设置x轴的风格,暂时没看明白有多大区别
yaxs = "i",
col = "red",#设置颜色
pch = 19)#pch指代点的形状,用数字表示,可查看帮助文档
#如果要保存图片怎么办呢?我觉得最简单的方法就是使用RStudio这个IDE,极其得好,可惜很多人都不知道。#如果你不会,可以用如下代码实现:#(图形的参数还有很多个,我这里只使用了其中的几个)
png(filename="散点图.png",width=480,height=480)
plot(cars$dist~cars$speed,#y~x
main="Relationship between car distance & speed",#标题
xlab = "Speed(miles per hour)",#x轴标题
ylab = "Distance travelled (miles)",#Y轴标题
xlim = c(0,30),#设置x轴的取值区间为0到30
ylim = c(0,140),#设置y轴的取值区间为0到140
xaxs = "i",#这里是设置x轴的风格,暂时没看明白有多大区别
yaxs = "i",
col = "red",
pch = 19)#pch指代点的形状,用数字表示,可查看帮助文档
dev.off()
09-12
6388
10-31
847
08-28
447