Munish
Munish

Reputation: 677

making y-axis labels bold in ggplot (x-axis is set bold but y-axis label doesn't change)

I am trying to set axis labels and ticks bold in ggplot but y-axis labels is not setting to bold. Please suggest what I should add to the script. Below is a reproducible example. I do need 'atop' command to set y-axis labels string as in the example below.

Thanks in advance.

library(ggplot2)

chart <- ggplot(diamonds, aes(x = table, fill = clarity)) +

geom_histogram() +

  scale_x_continuous('Month') + 

 scale_y_continuous(expression(atop('ET (W'~m^-2~')')))

chart<-chart+theme(axis.title.y = element_text(colour="grey20",size=20,face="bold"),
     axis.text.x = element_text(colour="grey20",size=20,face="bold"),
     axis.text.y = element_text(colour="grey20",size=20,face="bold"),  
     axis.title.x = element_text(colour="grey20",size=20,face="bold"))  

print(chart)

Upvotes: 3

Views: 19427

Answers (1)

BonnieM
BonnieM

Reputation: 331

I was having a similar problem and got this to work:

ylab(expression(atop(bold('ET (W'~m^-2~')'), paste(bold('something else'[here])))))

Hope that helps.

Upvotes: 1

Related Questions