R在ggplotly中垂直绘制文本标签不起作用

时间:2019-08-14 14:36:27

标签: r ggplot2 ggplotly

我有一个人进行的表面接触(在df1中)的时间序列,以及房间中的温度(每隔几秒钟测量一次,并存储在df2中)。我想在temperature上方和y轴下方(或在构面图中)绘制Dev.Date.Time,将它们相对于Surface所接触的Dev.Date.Time绘制出来。

head(df1)
  ActivityID CareType HCWType Orientation    Surface       Date     Time       Dev.Date.Time SurfaceCategories
1         01       IV    RN01  leftFacing AlcOutside 2019-08-03 11:08:01 2019-08-03 11:08:01       HygieneArea
2         01       IV    RN01  leftFacing         In 2019-08-03 11:08:12 2019-08-03 11:08:12                In
3         01       IV    RN01  leftFacing       Door 2019-08-03 11:08:12 2019-08-03 11:08:12        FarPatient
4         01       IV    RN01  leftFacing       Door 2019-08-03 11:08:18 2019-08-03 11:08:18        FarPatient
5         01       IV    RN01  leftFacing      Other 2019-08-03 11:08:22 2019-08-03 11:08:22        FarPatient
6         01       IV    RN01  leftFacing      Table 2019-08-03 11:10:26 2019-08-03 11:10:26       NearPatient

df2<-data.frame(sample(32:35,100,replace=T),Dev.Date.Time=seq(
     from=as.POSIXct("2012-1-1 0","%Y-%m-%d %H", tz="UTC"),
     to=as.POSIXct("2012-1-3 23", "%Y-%m-%d %H", tz="UTC"),
     by="10 seconds")
   )

使用以下代码有效,但是当我尝试将其放入ggplotly时,标签仍为水平且呈紫色。有什么想法吗? Plotting text labels from one dataframe along a time-series with a higher frequency R

p<-ggplot(df2, aes(x=Dev.Date.Time, y=Temperature)) +
    geom_line() + 
    geom_text(data=df1, aes(label=Surface),angle = 90, colour = "black",check_overlap = TRUE)

这就是我所追求的:

enter image description here

这就是我得到的:

require(ggplotly)
ggplotly(p)

enter image description here  #Edit

有解决方法吗?我知道这实际上是一个错误,但会感谢任何人的投入。

0 个答案:

没有答案