3

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)
Roland
  • 127,288
  • 10
  • 191
  • 288
Munish
  • 667
  • 3
  • 13
  • 34
  • 1
    This works for me. The answer might lie in the specific capabilities of your OS (i.e. typefaces installed, etc.). The output of `sessionInfo()` would be a start. – joran Jun 05 '13 at 19:00
  • I am using: R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) – Munish Jun 05 '13 at 19:19
  • Not in the comments! In your question! – joran Jun 05 '13 at 19:20
  • typing session info on output console gives me the R version and Platform as posted in prev. comment. Additionally attached base packages info displays: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.9.3 loaded via a namespace (and not attached): [1] colorspace_1.2-1 dichromat_2.0-0 digest_0.6.3 grid_2.15.2 [5] gtable_0.1.2 labeling_0.1 MASS_7.3-22 munsell_0.4 [9] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2 [13] scales_0.2.3 stringr_0.6.2 – Munish Jun 05 '13 at 19:26
  • You might find an answer to this question here: http://stackoverflow.com/questions/32803727/ggplot-scale-x-continuous-with-symbol-make-bold – MSJ Sep 28 '15 at 12:25

1 Answers1

1

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.

BonnieM
  • 191
  • 1
  • 13