user1322720
user1322720

Reputation:

Labelling every nth tick mark

I am plotting an axis with

a <- factor(letters[seq( from = 1, to = 26 )])
b <- 1:26
plot(a, b, axes = FALSE)
axis(1, at = a, labels = a, las = 2)

How can I get all the tick marks but only every nth label, e.g. (every 7th):

enter image description here

Upvotes: 3

Views: 5179

Answers (1)

user1981275
user1981275

Reputation: 13372

You can call axis twice, first to draw all tick marks and then again to put the labels:

c = a[seq(1, length(a),7)]
axis(1, at=a, labels = FALSE)
axis(1, at=c, labels = c, las = 2)

Upvotes: 1

Related Questions