使用ggplot2,我如何绘制一个在facet之间运行的趋势线.
library(ggplot2)
df <- data.frame(y=c(1,2,3),x=1,Set=LETTERS[1:3])
ggplot(df,aes(x,y)) +
theme_bw() + theme(legend.position=c(0,1),legend.justification=c(0,1)) +
geom_point(aes(fill=Set),color="black",shape=21,size=3) +
facet_grid(~Set) +
xlim(1,5)
Run Code Online (Sandbox Code Playgroud)
产生以下内容:
在上面,我想在这三点之间画一条线,横过小平面.
我正在尝试ggsignif使用facet_wrap 在成对的条形图顶部显示重要的星星。但是,我\xc2\xb4t 设法找到一种在每个方面显示一个重要条的方法。我的意思是:
dat <- data.frame(Group = c("S1", "S1", "S2", "S2"),\n Sub = c("A", "B", "A", "B"),\n Value = c(3,5,7,8))\n\n ggplot(dat, aes(Group, Value)) +\n geom_bar(aes(fill = Sub), stat="identity", position="dodge", width=.5) +\n geom_signif(y_position=c(5.3, 8.3), xmin=c(0.8, 1.8), xmax=c(1.2, 2.2),\n annotation=c("**", "NS"), tip_length=0) +\n scale_fill_manual(values = c("grey80", "grey20")) +\n facet_grid(~ Group, scales = "free")\nRun Code Online (Sandbox Code Playgroud)\n\n
有没有办法确保每个方面都有其各自的重要性标签?
\n