Following code produces a plot with y-axis on log scale:
ibrary(ggplot2)
library(tidyverse)
cars %>%
ggplot(aes(x = speed, y = dist)) +
geom_point() +
scale_y_continuous(trans = "log2", breaks = c(2, 4, 8, 16, 64, 128),
limits = c(2, 128)) +
annotation_logticks(sides = "l") +
theme_bw()
I want the axis tick marks to stop at 2. Please note, I do not wish to use the expand = c(0, 0) argument, since I want the white space around the plot. Is there a way to conditionally set the size of the small tick marks to NA if they are representing values less than 2?
I have found a few queries like this one which conditionally change the text that appears on the x-axis. Is there a similar or better way to do that with the tick sizes of the annotation_logticks?
Any help will be appreciated.
I am adding my actual plot for reference - the red box marks the ticks that need to be removed.