Exponential notation for tick labels in ggplot2

I figured this was worth noting in a post, since it took me some time to hunt down exactly what I was looking for via Google.

My problem arose when plotting spectra with log scale axes in R using ggplot2 with the scales package, i.e., with:


The default “scientific” notation is to present exponents in the form 1e+01, 1e+03, etc, whereas it is preferable to have 101, 103, etc. This can be accomplished by using this incantation instead:


Much better.

exponential notation in ggplot