我正在使用以下代码。
library(ggplot2)
library(dplyr)
mtcars$carb <- as.factor(mtcars$carb)
mtcars$carb <- as.factor(mtcars$carb)
mtcars$am <- as.factor(mtcars$am)
additions <- data.frame("carb" = c(1,2,3,4,6,8),
"words_eng" = c("one","two","three","four","six","eight"),
"words_spa" = c("uno","dos","tres","cuatro","seis","ocho"))
mtcars2 <- merge(mtcars, additions, by = "carb")
mtcars2 <- select(mtcars2, "carb", "am", "mpg", "words_eng", "words_spa")
mtcars2 <- mutate(mtcars2, joined = paste0(words_eng, "_", words_spa, "_", carb))
ggplot(mtcars2) +
geom_boxplot(aes(x = joined, y = mpg, fill = am),
position = position_dodge(0.9)) +
guides(fill = guide_legend(direction = "horizontal")) +
theme(axis.text.x = element_text(angle=90, vjust=0.5, hjust=1))
结果是:
如何修改x轴刻度标签内的字体样式和颜色,以使“一个”,“两个”,“三个”等以蓝色粗体显示,而“ uno”,“ dos”, tres”将以红色粗体显示,并且“ 1”,“ 2”,“ 3”等保留原样吗?谢谢。