Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make xlab and ylab visible when using theme_wsj {ggthemes}? [closed]

Tags:

r

ggplot2

You can see examples in this page.

Notice that in theme_wsj example, xlab and ylab do not appear.

Here's a non-ggthemes plot that includes labels:

ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
xlab("Hello World: X axis") +
ylab("Hello World: Y axis")

But, when you add the theme_wsj theme, they disappear:

ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_point() +
xlab("Hello World: X axis") +
ylab("Hello World: Y axis") +
theme_wsj()
like image 930
George Dontas Avatar asked Nov 20 '25 01:11

George Dontas


1 Answers

If you look on source code of theme_wsj() you can see that axis titles are set as blank

theme_wsj<-function(base_size=12, color="brown", base_family="sans", title_family="Courier") {
    colorhex <- ggthemes_data$wsj$bg[color]
    (theme_foundation()
     + theme(
.....
      axis.title=element_blank()
....

So one solution to get xlab and ylab to be shown is to add new theme element

+theme_wsj()+theme(axis.title=element_text(size=12))
like image 66
Didzis Elferts Avatar answered Nov 21 '25 14:11

Didzis Elferts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!