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

4
  • What do you get if you set breaks = seq(0, 0.5, 0.1) and labels = seq(0, 0.5, 0.1)? Commented Aug 23, 2020 at 0: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 Commented Aug 23, 2020 at 1: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) Commented Aug 23, 2020 at 1: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: stackoverflow.com/questions/11335836/… Commented Aug 23, 2020 at 1:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.