标记每个第n个刻度线

时间:2016-02-05 08:49:56

标签: r axis-labels

我正在用

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

如何获得所有刻度线,但只能每第n个标记,例如(每7天):

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以拨打axis两次,首先绘制所有刻度线,然后再贴上标签:

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