create breaks in scales on unique variable values

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.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.