我使用 GGPLOT 创建了一个 geom_bar 和
ggplot(MyDF, aes(x=type, y=count, fill=type)) +
geom_bar(stat = 'identity', position = "dodge", colour="black") +
labs(fill = "GROUP") +
labs(x = NULL, y = NULL, title = "*OUT OF*") +
scale_fill_manual(values=c("darkseagreen5","darkseagreen","darkseagreen4",
"indianred3","indianred1"),
labels = c("SCORE<10 & SCORE2<7",
"IMPV >= 55%",
"IMPV >= 35%",
"SCORE>17 OR SCORE2>14 OR IMPV<22%",
"BDI OR SCORE>SCORE2"))+
geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
geom_text(aes(label = count_n), position = position_dodge(0.9),
vjust=-0.3, colour = "black", size=4.6) +
scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))
我想在右侧的标签窗口 (GROUP) 中调整空格和字体(例如调整为 BOLD)。 我无法调整字体/大小/间隙/等... 你能帮我吗,我的目标是创建一个小标题,例如:
未响应:
答案 0 :(得分:1)
试试这个:
#Code
ggplot(MyDF, aes(x=type, y=count, fill=type)) +
geom_bar(stat = 'identity', position = "dodge", colour="black") +
labs(fill = "GROUP") +
labs(x = NULL, y = NULL, title = "*OUT OF 55 PATIENTS") +
scale_fill_manual(values=c("darkseagreen1","darkseagreen","darkseagreen4",
"indianred3","indianred1"),
labels = c("BDI<10 & HAM<7",
"IMPV >= 50%",
"IMPV >= 30%",
"BDI>17 OR HAM>14 OR IMPV<20%",
"BDI OR HAM Post>Pre"))+
geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
geom_text(aes(label = count_n), position = position_dodge(0.9),
vjust=-0.3, colour = "black", size=4.6) +
scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))+
theme(legend.text = element_text(face = 'bold'),
legend.title = element_text(face = 'bold'))
使用 ggtext
,您可以像这样自定义字体:
library(ggtext)
#Code 2
ggplot(MyDF, aes(x=type, y=count, fill=type)) +
geom_bar(stat = 'identity', position = "dodge", colour="black") +
labs(fill = "GROUP") +
labs(x = NULL, y = NULL, title = "*OUT OF 55 PATIENTS") +
scale_fill_manual(values=c("darkseagreen1","darkseagreen","darkseagreen4",
"indianred3","indianred1"),
labels = c("**WORSENED:**<br>BDI OT HAM Post>Pre",
"IMPV >= 50%",
"IMPV >= 30%",
"BDI>17 OR HAM>14 OR IMPV<20%",
"BDI OR HAM Post>Pre"))+
geom_text(aes(y = 0, label = count_per),size = 5, vjust = -0.6, nudge_y = .2) +
geom_text(aes(label = count_n), position = position_dodge(0.9),
vjust=-0.3, colour = "black", size=4.6) +
scale_y_continuous(limits = c(0, 30), breaks = seq(0,30, by = 5))+
theme(legend.text = element_markdown(),
legend.title = element_text(face = 'bold'))