在ggplot中的geom_area,qplot表现得非常奇怪。 geom_line,geom_ribbon没有类似的问题

时间:2016-03-19 20:02:05

标签: r ggplot2

以下是演示此问题的数据子集。

dat <- structure(list(days = structure(c(16784, 16784, 16784, 16784, 
16784, 16784, 16784, 16784, 16784, 16784, 16784, 16784, 16784, 
16784, 16784, 16784, 16784, 16784, 16784, 16784, 16784, 16785, 
16785, 16785, 16785, 16785, 16785, 16785, 16785, 16785, 16785
), class = "Date"), amount = c(88321.19, 88341.19, 88361.19, 
88386.19, 88406.19, 88606.19, 88646.19, 88686.19, 88736.19, 88786.19, 
88806.19, 88836.19, 88871.19, 88896.19, 88921.19, 88971.19, 88996.19, 
89068.36, 89098.36, 89148.36, 89248.36, 89348.36, 89369.16, 89469.16, 
89493.68, 89518.68, 89568.68, 89618.68, 89658.68, 89683.68, 89708.68
)), .Names = c("days", "amount"), row.names = c(NA, -31L), class = "data.frame")

ggplot(dat,aes(x=days, y=amount)) + geom_area()

运行这个,我看到一条坡度减小的线,这显然与数据相反。

a line with decreaing slope

即使用+ geom_area()替换+ geom_ribbon(data=exampleDat, aes(ymin=0, ymax=amount)) 也会产生正确的图片(大致扁平的黑框)。同样适用于geom_line()

当绘制整个数据集时,我得到绘图(轴指的是与之前相同的变量,两者都是非减少的):

plot with more days

任何见解都会非常感激。我之前从来没有遇到过这个问题。

0 个答案:

没有答案
相关问题