如何解决向每个多面ggplot2添加自定义的多个geom_vline
我有一个数据集,其中每个物种都与另一物种的特定密度(数字)和类型(数字)混合。我想在ggplot的每个facet_grid面板中添加两种垂直线:(a)固定密度/类型的固定线。例如1000/1 = 1000、1000 / 6 = 166.7、10000 / 1 = 10000、10000 / 6 = 1666.7set.seed(111)
count <- rbinom(500,100,0.1)
species <- rep(c("A","B"),time = 250)
density <- rep(c("1000","10000","1000","10000"),time = 125)
type <- rep(c("1","1","6","6"),time = 125)
df <- data.frame(species,density,type,count) # I feel too naiive,but I'm not able to get all the treatments filled. Gah.
ggplot(df,aes(x= count,colour = species,fill = species)) +
geom_histogram(position="identity",alpha=0.5) +
theme_bw() + ylab("Frequency") +
facet_grid(species ~ type + density) +
theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
theme(legend.position = "none") + theme(aspect.ratio = 1.75/1)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。