Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

ggplot2

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)
like image 393
Munish Avatar asked Dec 29 '25 11:12

Munish


1 Answers

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.

like image 113
BonnieM Avatar answered Dec 31 '25 03:12

BonnieM