30

I want to remove labels and axis from X axis, however adding new ticks.

plot(1:10, ylab = "")
at1 <- seq(1, 10, 0.1)
axis(side = 1, at = at1, labels = FALSE)

I could not get rid of y labels.

Sam
  • 7,252
  • 16
  • 46
  • 65
SHRram
  • 4,127
  • 7
  • 35
  • 53

2 Answers2

48

see ?par You need the xaxt argument

plot(1:10, ylab = "", xaxt='n')
GSee
  • 48,880
  • 13
  • 125
  • 145
  • is there a reason why you are using double quotes in `""` and single quotes in `'n'`? – Nisba Oct 11 '18 at 16:23
  • @Nisba personally I use `''` with a character and `""` with a string. – Rafs Jul 24 '20 at 14:12
  • This is not only suppressing the ticks, but also the labels. Example: plot.new() plot.window(xlim=c(0,1), ylim=c(0,1)) axis(1, xaxt='n', labels=0:1, at=0:1) – jmb Mar 04 '22 at 15:30
4

I am not certain what you want, but this removes the x label and uses the tick marks you are generating with at1:

plot(1:10, ylab = "", xlab="")
at1 <- seq(1, 10, 0.1)
axis(side =1, at1, labels = F)

I took the suggestion by GSee to remove the y tick marks if you also want to do that.

plot(1:10, xlab = "", ylab = "", yaxt='n')
at1 <- seq(1, 10, 0.1)
axis(side =1, at1, labels = F)
Mark Miller
  • 12,483
  • 23
  • 78
  • 132