Skip to content

Instantly share code, notes, and snippets.

@soh-i
Created January 5, 2024 22:03
Show Gist options
  • Save soh-i/1bf79b6a335a716db15f938770d9fd9f to your computer and use it in GitHub Desktop.
Save soh-i/1bf79b6a335a716db15f938770d9fd9f to your computer and use it in GitHub Desktop.
ggplot with nice log ticks
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")
@soh-i
Copy link
Author

soh-i commented Jan 5, 2024

Screen Shot 2024-01-05 at 14 05 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment