ggplot页脚中的多行

时间:2019-11-26 19:06:36

标签: r ggplot2

我正在尝试在条形图上显示页脚,但无法将其显示为垂直线。 我正在使用下面的图层,但是文本是水平打印的:

labs(caption ="IAT > 95%: OK        90% < IAT <=95%: Warning        IAT <= 90%: 5% Fee")

我以其他方式尝试过,但效果不佳:

1)labs(caption = paste("IAT > 95%: OK","\n","90% < IAT <=95%: Warning","\n","IAT <= 90%: 5% Fee"))

2)labs(caption = cat("IAT > 95%: OK","\n","90% < IAT <=95%: Warning","\n","IAT <= 90%: 5% Fee"))

此外,我只想以粗体显示“确定”,“警告”和“ 5%费用”标签。

这是我的情节:

ggplot(data = indicadorMensal, 
       aes(x = month_Year, y = qtd, label = qtd*100)) + 
  geom_col(aes(fill = OS),
           position = position_dodge2(width = 0.9, preserve = "single")) + 
  geom_text(position = position_dodge2(width = 0.9, preserve = "single"),
            vjust = 0.05, size = 3) +
  xlab("Year/Month") +
  ggtitle("IAT Plot",
          subtitle = paste(str_to_title(month(today()-30,
                                              label = TRUE, 
                                              abbr = FALSE)),
                           year(today()))) +
  theme(plot.title = element_text(hjust = 0.5), 
        plot.subtitle = element_text(face="bold",hjust = 0.5), 
        axis.title = element_text(face = "bold"), 
        legend.title = element_text(colour="black", size=11,face="bold"), 
        plot.caption = element_text(face = "italic", size=7)) +
    **labs(caption ="IAT > 95%: OK        90% < IAT <=95%: Warning IAT <= 90: 5% Fee")** +
  scale_fill_discrete(name = "Projects") +
  scale_y_continuous("IAT", labels = percent_format())

Plot

0 个答案:

没有答案