【发布时间】:2022-06-15 22:22:33
【问题描述】:
如何更改 ggplot2 中 x 轴标签的名称? 见下文:
ggbox <- ggplot(buffer, aes(SampledLUL, SOC)) + geom_boxplot()
ggbox <- ggbox + theme(axis.text.x=element_text(color = \"black\", size=11, angle=30, vjust=.8, hjust=0.8))
ggbox<- ggbox + labs(title = \"Land cover Classes\") + ylab(\"SOC (g C/m2/yr)\") + xlab(\"Land cover classes\")
上面的代码创建了下图:
我希望能够将这些类的第一个字母大写(即作物,而不是作物)。
我试过下面的代码,但不知道把它放在哪里以及到底要使用什么功能。
labels = c(\"Citrus\", \"Crop\", \"Cypress Swamp\", ..........)
(我使用的是 Windows 7,Rstudio)
-
请注意,
str_to_sentence可用于生成所需的大写方案。 stringr.tidyverse.org/reference/case.html