Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 6
    Actually the point would be to "generalize" the by argument, to different scales of numbers, i.e., 0.5 is a good value for this data which range is c(-3,3), but it's not a good range for a data which range is c(0,5000). Is there some function that calculates it? Commented Jul 4, 2012 at 22:33
  • 3
    @JoãoDaniel - I mean ggplot does a decent job at this automatically. If it isn't producing a satisfactory set of results, I'm not sure there's a built in function to provide something different. The level of detail you'll want will be specific to your plot, but maybe think through some test cases and your specified level of detail to identify a pattern...if this were a boxplot, something like max-min/30 is a pretty common "bucket" size...but that may or may not be a good starting point for you. Commented Jul 4, 2012 at 22:39
  • 5
    What about for categorical values on the x-axis like months of the year for time series? Commented Jul 29, 2015 at 15:50
  • 4
    @ScottDavis have a look at link. You can use scale_x_date(date_breaks = "5 months", date_minor_breaks = "1 months") Commented Jun 11, 2019 at 6:26
  • 3
    For zooming coord_cartesian should be used instead of xlim. stackoverflow.com/questions/25685185/… Commented Jul 15, 2019 at 15:55