Reputation: 55
How can I format the style of the grouped bar names in ggplot2? I would like to change the text color from grey to black. I've added a picture to clarify what I mean.
What I've got so far:
specify_decimal <- function(x, k) trimws(format(round(x, k), nsmall=k))
library(ggplot2)
ggplot(data, aes(type, hitrate, fill=Cache)) +
geom_bar(position=position_dodge(0.9), width=0.8, stat="identity") +
geom_errorbar(aes(ymin=hitrate-sd, ymax=hitrate+sd),width=0.3,position=position_dodge(0.9)) +
coord_cartesian(ylim = c(0, 0.8)) +
theme(axis.title.x=element_blank(),axis.ticks.x=element_blank()) +
scale_y_continuous(name="Hit Ratio") +
scale_fill_brewer(palette = "Set1") + geom_text(aes(label=specify_decimal(hitrate,8)), position=position_dodge(width=0.9), vjust=-0.45)
Many thanks!
Upvotes: 1
Views: 58
Reputation: 54257
Adjust your theme settings:
library(ggplot2)
ggplot(mpg, aes(class)) +
geom_bar() +
theme(axis.text.x = element_text(color = "red"))
Upvotes: 2