我有以下情节:
使用
生成all$lvl <- factor(all$Criteria, levels=c("A", "B", "C", "D"))
ggplot(all, aes(x=Date, y=Users, color=Answer, group=Answer)) +
geom_point(size=1.5) + geom_line(size=1.5) +
theme_hc() + theme(axis.text.x=element_blank(), axis.ticks.x=element_blank()) + facet_grid(.~lvl) +
scale_y_continuous(labels=percent)
该行将我的数据框中的值与x
和y
的离散值相关联。如何填充线下方的区域? geom_area
我得到了奇怪的结果:
geom_area(linetype=1, size=0.2, color="black", aes(fill=Answer))
我想这是因为geom_area
用于连续值。有没有办法为离散数据集执行此操作?叠加线条会使怪异变得更加明显:
我尝试了除stat
默认值以外的identity
的其他值,但没有成功。据我了解,identity
不应该更改数据......
答案 0 :(得分:2)
geom_area
默认为position = "stack"
,这就是两个颜色区域堆叠而不是重叠的原因。试试position = "identity"
。