我写了以下绘图命令:
Stripped_DATA <- structure(list(Epoch = structure(c(1110925802, 1110929408, 1110933014,
1110936616, 1110940217),
class = c("POSIXct", "POSIXt"),
tzone = "Europe/Helsinki"),
Timediff = c(-1.4653909261659, -1.46512243581845,
-1.46505141447328, -1.46503418192427, -1.46464648029912)),
.Names = c("Epoch", "Timediff"),
row.names = c("11070", "21070", "31070", "41070", "51070"),
class = "data.frame")
plot(Stripped_DATA, main = "Maser-69 hourly averages raw data, -3 < 3 microseconds", xlab = "Date", ylab = "microseconds")
ticks <- seq(as.POSIXct("2005-03-16 00:30:02", format = "%F %T"),
as.POSIXct("2019-04-19 14:29:55", format = "%F %T"), by = "4 months")
labels <- seq(as.Date("2005-03-16"), as.Date("2019-04-19"), by = "4 months")
axis.POSIXct(1, at = ticks, format = "%Y-%m-%d %H", labels = labels)
给出图中所示的x轴。如何消除与日期重叠的三个年度滴答?另外,有没有办法将日期标签从水平方向更改为垂直方向,以便我可以添加更多日期标签?
答案 0 :(得分:1)
使用评论中提供的数据。请注意mischva11中的评论以及下面的链接。
Rotating x axis labels in R for barplot
仅需要las = 2
函数中的plot
自变量。
Stripped_DATA <- structure(list(Epoch = structure(c(1110925802, 1110929408, 1110933014,
1110936616, 1110940217),
class = c("POSIXct", "POSIXt"),
tzone = "Europe/Helsinki"),
Timediff = c(-1.4653909261659, -1.46512243581845,
-1.46505141447328, -1.46503418192427,
-1.46464648029912)),
.Names = c("Epoch", "Timediff"), row.names = c("11070", "21070",
"31070", "41070",
"51070"),
class = "data.frame")
plot(Stripped_DATA, main = "Maser-69 hourly averages raw data, -3 < 3 microseconds",
xlab = "Date", ylab = "microseconds",
las = 2) # see
ticks <- seq(as.POSIXct("2005-03-16 00:30:02", format = "%F %T"),
as.POSIXct("2019-04-19 14:29:55", format = "%F %T"), by = "4 months")
labels <- seq(as.Date("2005-03-16"), as.Date("2019-04-19"), by = "4 months")
axis.POSIXct(1, at = ticks, format = "%Y-%m-%d %H", labels = labels)
答案 1 :(得分:1)
如果您只想使用刻度线,请在使用def enableProguardInReleaseBuilds = true
进行打印之前,从图中删除标签,并使用xaxt='n'
旋转图标签。
las=2
说明:您的 plot(Stripped_DATA, main = "Maser-69 hourly averages raw data, -3 < 3 microseconds",
xlab = "Date", ylab = "microseconds" , las=2, xaxt="n")
ticks <- seq(as.POSIXct("2005-03-16 00:30:02", format = "%F %T"),
as.POSIXct("2019-04-19 14:29:55", format = "%F %T"), by = "4 months")
labels <- seq(as.Date("2005-03-16"), as.Date("2019-04-19"), by = "4 months")
axis.POSIXct(1, at = ticks, format = "%Y-%m-%d %H", labels = labels, las=2)
函数添加了其他标签。这些可以与您的图标签重叠,并创建您显示的输出。因此,请勿使用axis.POSIct()
请注意,这只是如果您只想拥有xaxt='n'
标签