R高水平绘图
基本绘图函数——plot
根据刹车距离与车速数据,输出他们关系图
data(cars)
attach(cars)
j=1
par(mai=c(0.9, 0.9, 0.6, 0.3))
for(i in c("p","l","b","c","o","h","s","S","n"))
{
plot(speed,dist,type=i, main = paste("type=\"",i,"\"",sep=""))
if(i=="S")
i="S2"
fileName = paste("carPlot_",j,i,sep = "")
savePlot(filename = fileName, type="png")
j=j+1
}
detach()
多组图——pairs函数
根据年龄、身高、体重输出他们之间关系的多组图
df<-data.frame(
Age = c(13, 13, 14, 12, 12, 15, 11, 15, 14, 14, 14, 15, 12, 13, 12, 16, 12, 11, 15),
Height = c(144,166,163,143,152,169,130,159,160,175,161,170,146,159,150,183,165,146,169),
Weight = c(38.1,44.5,40.8,34.9,38.3,50.8,22.9,51.0,46.5,51.0,46.5,60.3,37.7,38.1,45.1,68.0,58.1,38.6,50.8)
)
pairs(df)
savePlot(filename="Pairs_Age_Weight_Height",type="png")