[英]Move x-axis labels down from x-axis
x<- structure(list(count = c(4259120, 4317840, 4444000, 4254240,
4656800), the_date = structure(c(1389589200, 1389675600, 1389762000,
1389848400, 1389934800), class = c("POSIXct", "POSIXt"), tzone = "")), .Names = c("count",
"the_date"), row.names = c(51L, 406L, 664L, 197L, 196L), class = "data.frame")
par(mar = c(8, 4, 4, 2) + 0.1)
plot(x$the_date, x$count, type="l", xaxt = "n", xlab = "")
axis(1, labels = FALSE)
labels<-x$the_date
labels<-format(labels, format="%b-%d-%Y")
text(x$the_date, par("usr")[3] - 0.75, srt = 55, adj = 1, labels = labels, xpd = TRUE)
I've tried adjusting the par("usr")[3] - 0.75
offset as specified here , but the labels aren't moving at all. 我试过调整
par("usr")[3] - 0.75
此处指定的par("usr")[3] - 0.75
偏移量,但是标签根本没有移动。
You can a trick like this using 2 calls to axis
functions. 您可以通过两次调用
axis
函数来获得类似的技巧。 I am using here axis.Date
since you deal with dates(better for formatting). 我在这里使用
axis.Date
因为您处理日期(更好地格式化)。 Then you can ply with line
argument t play with labels positions. 然后,您可以使用
line
参数t来播放标签位置。
axis(1,labels=FALSE)
axis.Date(1,at = x$the_date,las=2, format= "%m-%d",line=0.5,tick=FALSE)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.