0

I know that it is possible to "supress" some axis labels by implementing a hack like this:

# consider the range of the x variable to be between 0 and 1
ggplot(data = df, aes(x = x, y = y)) +
  geom_point() +
  scale_x_continuous(breaks = seq(0, 1, 0.1), labels = append(seq(0, 0.5, 0.1), rep("", 4)))

Here I would only be showing the x axis labels from 0 through 0.5 and the tick marks at 0.6-1 would be "empty", however I also want to remove those tick marks while keeping the ones from 0 to 0.5

MikeKatz45
  • 545
  • 5
  • 16
  • What do you get if you set `breaks = seq(0, 0.5, 0.1)` and `labels = seq(0, 0.5, 0.1)`? – jared_mamrot Aug 23 '20 at 00:56
  • 1
    that works, D: but its only because the marks that I want to remove are consecutive. I was thinking about removing any tick mark you wanted arbitrarily – MikeKatz45 Aug 23 '20 at 01:03
  • 1
    You want it arbitrary, you have to do it the hard way ;) `breaks = c(0.2, 0.46, 0.86)` and `labels = c(0.2, 0.46, 0.86)` – Ben Toh Aug 23 '20 at 01:07
  • 2
    Yep - what @BenToh said - you might also want to remove gridlines if it looks weird having them on only part of the plot using `+ theme(panel.grid.major.y = element_blank(), panel.grid.minor.y = element_blank())`. More details here: https://stackoverflow.com/questions/11335836/increase-number-of-axis-ticks – jared_mamrot Aug 23 '20 at 01:15

0 Answers0