ggplot2标签字体粗体无法正常工作

时间:2020-09-23 14:37:53

标签: r ggplot2

我正在尝试创建一个突出显示子组的箱形图。

library(ggplot2)
library(dplyr)
library(hrbrthemes)

mpg1 <- mpg %>% 
  mutate( type=ifelse(class=="subcompact","Highlighted","Normal"))
  
mpg1 %>%
  ggplot( aes(x=class, y=hwy, fill=type, alpha=type)) + 
  geom_boxplot() +
  scale_fill_manual(values=c("#69b3a2", "grey")) +
  scale_alpha_manual(values=c(1,0.1)) +
  theme_ipsum() +
  theme(legend.position = "none",
        axis.text = element_text(face = "bold")) +
  xlab("")

但是,正如您在此处的图像中看到的那样,某些x轴标签未正确加粗。我认为只有字母“ e”会发生这种情况。

letter e not getting bolded.

1 个答案:

答案 0 :(得分:0)

您可复制的代码片段按预期工作。关闭R / RStudio的所有实例,然后重试。也许R会话在终端/命令提示符中打开了?或者执行dev.off(),直到您打出Error in dev.off() : cannot shut down device 1 (the null device)消息为止。然后再次创建您的情节。