Datetime 使用ggplot2从轴上的POSIXct对象打印时间

Datetime 使用ggplot2从轴上的POSIXct对象打印时间,datetime,ggplot2,label,axis,posixct,Datetime,Ggplot2,Label,Axis,Posixct,我有一个基于一些时间相关数据的样条插值(x和y值)的数据帧splineset,dfdf有列df$value和df$time,其中time是POSIXct datetime对象,value是数字 splineset是使用splineset Hi创建的。这个问题还存在吗?请帮助我们将dput(head(splineset,20))的输出发布到问题中,同时请仅选择实际用于绘图的列。您当前的绘图正在geom_point中绘制df,不确定是否有意这样做。我想在同一绘图上显示原始数据和样条曲线插值!您的数据

我有一个基于一些时间相关数据的样条插值(x和y值)的数据帧
splineset
df
df
有列
df$value
df$time
,其中
time
是POSIXct datetime对象,
value
是数字


splineset
是使用
splineset Hi创建的。这个问题还存在吗?请帮助我们将
dput(head(splineset,20))
的输出发布到问题中,同时请仅选择实际用于绘图的列。您当前的绘图正在
geom_point
中绘制
df
,不确定是否有意这样做。我想在同一绘图上显示原始数据和样条曲线插值!您的数据框包含
x
,作为奇怪格式的日期类和
x.time
,在我看来,这似乎是您要绘制的列(这是在POSIXct中)
ggplot()+geom_line(data=splineset,aes(x=x.time,y=y))
工作正常,在x轴上给出了一个很好的日期图表。如果x确实也是POSIX,您应该能够在其上绘制来自
df
的变量
base <- ggplot(df, aes(x = time, y = value)) +
        geom_point() +
        geom_line(data = splineset, aes(x = x, y = y))

base
structure(list(x = structure(c(1420261200, 1420294782.72251, 
1420328365.44503, 1420361948.16754, 1420395530.89005, 1420429113.61257, 
1420462696.33508, 1420496279.05759, 1420529861.7801, 1420563444.50262, 
1420597027.22513, 1420630609.94764, 1420664192.67016, 1420697775.39267, 
1420731358.11518, 1420764940.8377, 1420798523.56021, 1420832106.28272, 
1420865689.00524, 1420899271.72775), class = "Date"), y = c(4748.5, 
4212.52512190184, 5425.53465349697, 7799.44656819583, 10683.9379760372, 
13353.4154924385, 15152.5922945744, 15891.6831978947, 15561.4833407268, 
14317.8145462586, 12609.7380342676, 10887.8275183587, 9315.03076879911, 
7888.68545478638, 6604.14143895759, 5456.74858394579, 4441.85675236009, 
3554.81580684035, 2790.97560999938, 2145.68602447347), x.time = structure(c(1420261200, 
1420294782.72251, 1420328365.44503, 1420361948.16754, 1420395530.89005, 
1420429113.61257, 1420462696.33508, 1420496279.05759, 1420529861.7801, 
1420563444.50262, 1420597027.22513, 1420630609.94764, 1420664192.67016, 
1420697775.39267, 1420731358.11518, 1420764940.8377, 1420798523.56021, 
1420832106.28272, 1420865689.00524, 1420899271.72775), class = c("POSIXct", 
"POSIXt"), tzone = "America/Indianapolis")), row.names = c(NA, 
20L), class = "data.frame")