I searched and found a similar post in Python not R. I am using Richie Cotton's code in this post Logarithmic y-axis Tick Marks in R plot() or ggplot2(). I don't want to display all labels for minor ticks, I only want to display major ticks such as 1, 10, 100 etc. Please see an exampled image below, that's why I don't want to display all minor tick's labels. I tried to remove "labels=breaks" in the code, but nothing happened.
library(ggplot2)
dfr <- data.frame(x = 1:100, y = rlnorm(100))
p <- ggplot(dfr, aes(x, y)) +
geom_point() +
scale_x_log10(breaks = breaks, labels = breaks)
get_breaks <- function(x){
lo <- floor(log10(min(x, na.rm = TRUE)))
hi <- ceiling(log10(max(x, na.rm = TRUE)))
as.vector(10 ^ (lo:hi) %o% 1:9)
}
breaks <- get_breaks(dfr$x)
log10_breaks <- log10(breaks)
p + labs(axis.ticks = element_line(
size = ifelse(log10_breaks == floor(log10_breaks), 2, 1)
))
ggplot(dfr, aes(x, y)) + geom_point() + scale_x_log10()
? I'm not sure I understand. – MrFlick