-
-
Save soh-i/1bf79b6a335a716db15f938770d9fd9f to your computer and use it in GitHub Desktop.
ggplot with nice log ticks
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
LINE.W <- 0.232 # 0.5pt | |
breaks_log10 <- function(x) { | |
low <- floor(log10(min(x))) | |
high <- ceiling(log10(max(x))) | |
10^(seq.int(low, high)) | |
} | |
... scale_y_log10( | |
limits = c(1e-3, 10), | |
breaks = breaks_log10, | |
labels = trans_format("log10", math_format(10^.x)) | |
) + | |
labs(x = "", y = "") + | |
annotation_logticks(sides = "l", size = LINE.W, outside = TRUE, short = unit(0.04, "cm"), mid = unit(0.07, "cm"), long = unit(0.1, "cm")) + | |
coord_cartesian(clip = "off") | |
Author
soh-i
commented
Jan 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment