Tuesday, December 18, 2012

R graphics plot types

scatter plot types

  • we use the tree data set as example data set
head(trees)

Girth Height Volume
1   8.3     70   10.3
2   8.6     65   10.3
3   8.8     63   10.2
4  10.5     72   16.4
5  10.7     81   18.8
6  10.8     83   19.7

par(mfrow=c(3,3))
plot(trees$Girth,trees$Height,type="p",main="type='p'") ## points
plot(trees$Girth,trees$Height,type="l",main="type='l'") ## a line
plot(trees$Girth,trees$Height,type="b",main="type='b'") ## both
plot(trees$Girth,trees$Height,type="o",main="type='o'") ## both overplotted
plot(trees$Girth,trees$Height,type="c",main="type='c'") ## lines like in "b" 
plot(trees$Girth,trees$Height,type="h",main="type='h'") ## vertical lines
plot(trees$Girth,trees$Height,type="s",main="type='s'") ## stair steps (first horizontal)
plot(trees$Girth,trees$Height,type="S",main="type='S'") ## stair steps (first vertical)
plot(trees$Girth,trees$Height,type="n",main="type='n'") ## none

No comments :

Post a Comment