我想在toupper
的{{1}}来电中致电aes
。例如,使用ggplot2
我想将变量PlantGrowth
更改为所有大写字母。我已经能够将x标签更改为全部大写,但是x轴标题会出现一个奇怪的标题。我可以手动删除x轴标题,但似乎有一种更简单的方法。
编辑1:我应该说我宁愿不改变数据框中的数据,即group
。相反,如果可能的话,我想更改d$group <- toupper(d$group)
语句中的标签。
aes
由于 -cherrytree
答案 0 :(得分:1)
使用levels()
library (ggplot2)
d <- PlantGrowth
levels(d$group) = toupper(levels(d$group))
ggplot() + geom_bar(data=d, aes(x=group,y=weight), stat='identity')
编辑: 不会更改data.frame版本
library (ggplot2)
d <- PlantGrowth
ggplot() + geom_bar(data=d, aes(x=group,y=weight), stat='identity') + scale_x_discrete(label = toupper(levels(d$group)))
答案 1 :(得分:0)
无需添加任何其他选项,就可以使用library(tidyverse)
来mutate
和x=group
toupper
的名称。例如,{{1}之前的%>% mutate(group= toupper(group)) %>%
。