章节 5 高级绘图函数
5.1 堆砌区域图
#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
)
eArea(df2, xvar=~weekDay, yvar= ~saleNum, series=~seller)
5.2 K线图
mat = rbind(c(2286.33,2299.99,2281.9,2309.39),
c(2297.11,2305.11,2290.12,2305.3),
c(2303.75,2302.4,2292.43,2314.18),
c(2293.81,2275.67,2274.1,2304.95),
c(2281.45,2288.53,2270.25,2292.59),
c(2286.66,2293.08,2283.94,2301.7),
c(2293.4,2321.32,2281.47,2322.1),
c(2323.54,2324.02,2321.17,2334.33),
c(2316.25,2317.75,2310.49,2325.72),
c(2320.74,2300.59,2299.37,2325.53),
c(2300.21,2299.25,2294.11,2313.43),
c(2297.1,2272.42,2264.76,2297.1),
c(2270.71,2270.93,2260.87,2276.86),
c(2264.43,2242.11,2240.07,2266.69),
c(2242.26,2210.9,2205.07,2250.63),
c(2190.1,2148.35,2126.22,2190.1)
)
rownames(mat) = Sys.Date()-(16:1)
eCandle(mat)
5.3 漏斗图
5.4 平行坐标
5.5 雷达图
require(plyr)
dat = ddply(iris, .(Species), colwise(mean))
rownames(dat) = dat[,1]
dat = dat[, -1]
dat
## 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
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))
)
dat <- df2
xvar=~weekDay; yvar= ~saleNum; series=~seller
eRadar(df2, ~weekDay, ~saleNum, ~seller)
5.7 桑基图
dat = data.frame(source=c("Agricultural 'waste'","Bio-conversion",
"Bio-conversion","Bio-conversion","Bio-conversion",
"Biofuel imports","Biomass imports","Coal imports",
"Coal reserves","Coal","District heating","District heating",
"District heating","Electricity grid","Electricity grid"),
target=c("Bio-conversion","Liquid","Losses","Solid","Gas","Liquid",
"Solid","Coal","Coal","Solid","Industry","Heating and cooling - commercial",
"Heating and cooling - homes","Over generation / exports","Heating and cooling - homes"),
value=c(124.729,0.597,26.862,280.322,81.144,35,35,11.606,63.965,75.571,
10.639,22.505,46.184,104.453,113.726))
eSankey(dat)