I often need to create custom breaks for axis or color/fill/size to reflect the actual data point. Typically in my data, the variable is continuous, but the measurement is at discrete points. I think this may apply to many others from what I see on SO. Below is an example of plotting mpg vs. cyl:
mpg %>%
ggplot(aes(cyl, cty)) +
geom_point() +
scale_x_continuous(breaks = unique(mpg$cyl))
But one does not really want to type different "mpg$cyl" for different exploratory data analysis all the time. So I am here to look for a general solution.
p.s. I read that ggplot does not pass the data to the scale
functions -- probably just the range for calculation. I filed an issue but have not yet get any response.