I have a ggplot2
plot,histogram produced as follows:
library("ggplot2")
library("scales")
df <- data.frame(test = rnorm(1000, 1000, 40000))
p <- ggplot(df, aes(x = test)) + geom_histogram(colour="black", fill="#FF9999")
# set themes, axes and labels
p <- p + theme_minimal() + theme() + xlab("Distance travelled [km]") + ylab("Count of users")
# transformation
p <- p + scale_x_log10(breaks = trans_breaks("log10", function(x) {10^x}),
labels = trans_format("log10", math_format(10^.x))
)
# plot
p
Output:
I used the scales
package to display x axis labels as powers of ten, but actually, I would like to display them as decimal numbers, as long as the number is below, let's say 10^4 and 10^-4, for the below plot, this would give the following axis labels
100
1000
10^4
10^5
How can I do this within trans_format(), or is there another, better solution?