通过plot绘制点线图
生成随机数据Runif()
1.生成180-240之间的30个数据
runif(30,180,240) # 生成180-240之间的30个数据
2.不要小数点
round(runif(30,180,240)) # 不要小数点
3.从1:10个数字之间取6个随机样本
sample(1:10,6,replace=T)
4.去重
sample(1:10,6,replace=False)
生成数据
data <-runif(10,40,90)
plot(data,type="p",main="绘点图",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="p",main="绘点图",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data1,type="l",main="绘点线",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="b",main="同时绘制点和线",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="c",main="仅绘制参数b所示的线",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="o",main="同时绘制点和线,且线穿过点",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="h",main="绘制出点到横坐标轴的垂直线",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="s",main="绘制出阶梯图(先横后纵)",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="S",main="绘制出阶梯图(先纵后竖)",xlab="x轴",ylab="y轴",col=c("red","blue","pink"))
plot(data,type="n",main="空图",xlab="x轴",ylab="y轴")
type图形的类型
(1)type为一个字符的字符串,用于给定绘图的类型,可选的值如下:
- “p”:绘点(默认值);
- “l”:绘制线;
- “b”:同时绘制点和线;
- “c”:仅绘制参数”b”所示的线;
- “o”:同时绘制点和线,且线穿过点;
- “h”:绘制出点到横坐标轴的垂直线;
- “s”:绘制出阶梯图(先横后纵);
- “S”:绘制出阶梯图(先纵后竖);
- “n”:作空图。