Created
September 15, 2010 04:00
-
-
Save strongh/580220 to your computer and use it in GitHub Desktop.
dollar-log formatting example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Homer Strong, September 2010 | |
## | |
## This is an example of using dollar formatting with log10 scaling. | |
## See the commit | |
## http://github.com/strongh/ggplot2/commit/7402a13a8ad625a8acd3024c5726545a20ac838e | |
library(ggplot2) | |
data(diamonds) | |
## On the current ggplot, the formatter argument is ignored when using | |
## either scale_*_<trans>() or scale_*_continous(trans='<trans>'). | |
## I wanted to use the log10 trans but keep the 'dollar' formatting, as with | |
ggplot(diamonds, aes(price)) + geom_histogram() + scale_x_continuous(trans='log10', formatter='dollar') | |
## The x-axis labels are formatted now as '$10^4' (with the superscript properly raised), as | |
## opposed to '10^4'. Even if there is another way to accomplish this, I feel like it's a | |
## consistent use of the formatting options. | |
## | |
## By the way, the plot above can be found in the downloads section of my ggplot2 fork, | |
## http://github.com/strongh/ggplot2/downloads |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment