我一直在try 创建一个自定义条形图,在这里我可以更改每组的 colored颜色 和图案(条纹或无条纹).
structure(list(Level= c(0.2, 0.3, 0.25, 0.35, 0.4, 0.5, 0.5, 0.6, 0.15, 0.35), Group= c("A", "A",
"B", "B", "C", "C", "D", "D",
"E", "E"), Condition = c("no", "yes", "no", "yes", "no", "yes", "no",
"yes", "no", "yes")), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
I have tried the following which creates the graph below.
I would however like to have both groups in white color, and if the bars where the condition == yes have black stripes in them as often seen in ggpattern plots.
使用ggpattern,我找不到可行的解决方案[Error in seq.default(from,to,by):invalid'(to-from)/by']是我遇到最多的错误之一.
p<- ggplot(z, aes(fill=Condition, y=Level, x=Group, pattern = Condition)) +
geom_bar(position="dodge", stat="identity") +
ggpubr::theme_pubr() +
theme(legend.position = "top") +
theme( panel.background = element_rect(colour = "black", size=0.5)) +
labs(x = "Group", y = "Level")+
scale_y_continuous(breaks=seq(0, 0.8, 0.1))+
scale_fill_discrete(name = "", labels = c("No", "Yes"))