章节 4 基本绘图函数
4.1 散点图
散点图需要的输入是data.frame,需要指定xvar
和yvar
, series
为可选的颜色分度参数,
4.2 线图
## N.Amer Europe Asia S.Amer Oceania Africa Mid.Amer
## 1951 45939 21574 2876 1815 1646 89 555
## 1956 60423 29990 4708 2568 2366 1411 733
## 1957 64721 32510 5230 2695 2526 1546 773
## 1958 68484 35218 6662 2845 2691 1663 836
## 1959 71799 37598 6856 3000 2868 1769 911
## 1960 76036 40341 8220 3145 3054 1905 1008
#mode 2 input.
df2 <- data.frame(
saleNum=c(10,20,30,40,50,60,70,15,25,35,45,55,65,75,25,35,45,55,65,75,85),
seller=c(rep("Yellow",7), rep("Red",7), rep("White",7)),
weekDay = c(rep(c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),3)),
stringsAsFactors =FALSE
)
eLine(df2, xvar=~weekDay, yvar= ~saleNum, series=~seller)
4.3 条形图
## Loading required package: plyr
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## redFlower 5.035000 3.480000 1.435 0.2350000
## setosa 4.986667 3.393333 1.480 0.2533333
## versicolor 5.936000 2.770000 4.260 1.3260000
## virginica 6.588000 2.974000 5.552 2.0260000
#mode 2 input.
df2 <- data.frame(
saleNum=c(10,20,30,40,50,60,70,15,25,35,45,55,65,75,25,35,45,55,65,75,85),
seller=c(rep("Yellow",7), rep("Red",7), rep("White",7)),
weekDay = c(rep(c("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),3)),
stringsAsFactors =FALSE
)
dat <- df2
xvar=~weekDay; yvar= ~saleNum; series=~seller
eBar(df2, xvar = ~seller, ~saleNum, ~weekDay )