我正在为 ggpubr 中的传奇位置而苦苦挣扎。我知道我可以将图例位置 pe 修改为ggpar(legend = "bottom")
. 但是,如何将图例标题放在图例键上方?
在ggplot2
中,似乎guide_legend(title.position = "top")
应该这样做,但是如何使它与 一起工作ggpubr
?(感谢@c06n 并在此处链接:https ://ggplot2.tidyverse.org/reference/guide_legend.html )。我想结合ggplot2
andggpubr
但我不知道为什么。
虚拟示例:
df2 <- data.frame(supp=rep(c("VC", "OJ"), each=3),
dose=rep(c("D0.5", "D1", "D2"),2),
len=c(6.8, 15, 33, 4.2, 10, 29.5))
# Plot "len" by "dose" and
# Change line types and point shapes by a second groups: "supp"
p<- ggline(df2, "dose", "len",
linetype = "supp", shape = "supp",
color = "supp", palette = c("#00AFBB", "#E7B800"))
# Seems not working
ggpar(p,
linetype = guide_legend(title = "My title", title.position = "top"))