25

I need to get tick marks with labels for intervals at 10 instead of 20 as shown in the image below - how to get tick marks with labels at intervals of 10 for x-axis and intervals of 5 for y-axis

The original x axis vector has data like [10, 20, 30, 40, 50, 60] for all series and y-axis vector has data like [1.67, 3.3, 5, 6.67, 8.3,10] for one series and like-wise for other two series.

ggplot below

zx8754
  • 52,746
  • 12
  • 114
  • 209
user3206440
  • 4,749
  • 15
  • 75
  • 132

1 Answers1

49

I advise you to add some of your code, so that it is easier for people to help you here.

To answer your question, you could use the breaks option in the scale family. For instance,

g <- ggplot(...) + ...
g + scale_x_continuous(breaks = seq(10, 60, by = 10))
  + scale_y_continuous(breaks = seq(0, 10, len = 5))
user3206440
  • 4,749
  • 15
  • 75
  • 132
Boxuan
  • 4,937
  • 6
  • 37
  • 73
  • 11
    It would be nice if there is a way to specify the frequency of breaks, w/o having to specify the upper end point. – steveb Feb 07 '21 at 06:50
  • 1
    A solution exists using `scales` package [see example here](https://stackoverflow.com/a/27911053/11494541) – Vizcachart Nov 19 '21 at 09:40