geom_GeomLabel()尚未以绘图方式实现

时间:2018-10-31 06:18:06

标签: r dataframe ggplot2 plotly

将ggplot转换为plotyly时出现此错误。 该怎么办?

我的代码:

p  <- ggplot(data_, aes(data_$dates,group = 1)) +
      geom_point(aes(y = data_$exp))+
      geom_point(aes(y = data_$actual))+
      geom_line(aes(y = data_$exp, color='Expected')) + 
      geom_line(aes(y = data_$actual, color='Actual'))+
      geom_label(aes(y = data_$exp,label = data_$exp,hjust = 0,vjust = -0.2))+
      geom_label(aes(y = data_$actual,label = data_$actual,hjust = 0,vjust = 0.2 ))+
      labs(title = "Avail")+
      labs(x="Dates")+
      labs(y="")+
      guides(color = guide_legend(title = ""))

output$trendPlot <- renderPlotly({
 ggplotly(p)
  })

我遇到错误:

geom_GeomLabel() has yet to be implemented in plotly.
  If you'd like to see this geom implemented,
  Please open an issue with your example code at
  https://github.com/ropensci/plotly/issues
Warning in origRenderFunc() :
  Ignoring explicitly provided widget ID "85055e160099"; Shiny doesn't use them

1 个答案:

答案 0 :(得分:0)

该错误表示plotly目前无法处理geom_label中的ggplot2。如错误提示所示,可以做的一件事是在https://github.com/ropensci/plotly/issues打开一个问题。但是,碰巧geom_text确实有效,因此用它替换geom_label是最简单的解决方案。