我在同一图表中绘制了4个不同的箱线图。我想更改x轴和y轴标签。
我想将RSQ_STB_BMI更改为BMI,并将T1_SB_OSA更改为T1 This is the output这是我的脚本,
db1<- dt %>%
dplyr::select("RSQ_STB_BMI","T1_SB_OSA","T2_SB_OSA","T3_SB_OSA","PP_SB_OSA")
db1 %>%
gather(variable, value, -RSQ_STB_BMI) %>%
ggplot(aes(factor(value), RSQ_STB_BMI, fill = factor(value))) +
geom_boxplot() + ggtitle('Boxplot of BMI by the Risk of Sleep Apnea')+
scale_fill_manual(values = c('#97e095','#4c9f83','#1c4f60'))+
theme(plot.title = element_text(hjust = 0.5))+facet_grid(~factor(variable, levels=c("T1_SB_OSA","T2_SB_OSA","T3_SB_OSA","PP_SB_OSA")),switch = "both")+
theme_bw()+
theme(panel.spacing = unit(0, "lines"),
panel.border = element_rect(fill = NA),
strip.background = element_blank(),
axis.title.x = element_blank(),
legend.position = "none",
strip.placement = "outside")
legend.position = "none",
strip.placement = "outside")`
1条答案
按热度按时间xxe27gdn1#
假设您要修改条带标签,而不是x轴标题,则可以在
facet_wrap
中执行此操作,如下所示:...或完全忽略原始面标签: