I have data that is the duration in seconds (an integer) for a specific type of event. A few durations are days long, some are hours long, more are minutes long, but must are seconds long. I want to histogram this data, and given that the majority of values are small, I want the x-axis to be on the log10 scale.
I know how to format the x-axis labels to that they are expressed as powers of ten, for example: 10^1, 10^2, 10^3, and so on. This is not what I want! For example, 10^5 seconds is not easily understandable, and it would make more sense to express this value in units of hours or days.
What I want is an axis with labelling that looks something like this:
1 second, 10 seconds, 1 minute, 10 minutes, 1 hour, 10 hours, 1 day, 1 week, 1 month, 1 year... etc.
(Bonus points if durations less than 1 second are expressed in ms, μs, ns and very long durations in ka, Gy, etc.)
Use scale_x_log10() with breaks and labels parameters from ggplot2
df <- data.frame(time=c(1,10,100,10000),value=c(5,10,50,20))
ggplot(df,aes(x=time,y=value))+
geom_point()+
scale_x_log10(breaks=c(1,60,3600),labels=c("1sec","1min","1hour"))
So breaks will be the number of seconds and labels the translation of seconds into something more readable (in this example 1sec, 1min and 1hour)