Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change axis-label color in ggplot2?

Tags:

r

ggplot2

I have tried

... + xlab("New label", colour="darkgrey")

and

... + xlab("New label", color="darkgrey")

But it says this argument is unused. I look into ?xlab, but it doesn't include any color parameter. Is it possible to change it? How?

like image 362
João Daniel Avatar asked May 01 '12 15:05

João Daniel


1 Answers

Since ggplot2 0.9.2, the syntax has become:

dat <- data.frame(x = 1:5,y = 1:5)
p + theme(axis.title.x = element_text(colour = "red"),
          axis.title.y = element_text(colour = "blue"))

The tidyverse page is a good starting point for learning about all the options.

Note that the old syntax based on opts has been deprecated. There is detailed transition guide for updating your code.

like image 55
joran Avatar answered Sep 20 '22 17:09

joran