【发布时间】:2018-11-15 11:57:28
【问题描述】:
我有一个通过 R(不是闪亮的应用程序)脚本正确显示的动画情节:
load("HF.RData") # this contains the dataframe dt1.HF
p <- ggplot(dt1.HF, aes(x = tm, y = HF, colour = team)) +
geom_point(aes(frame = sn, ids = tm), size = 5)
p <- ggplotly(p)
animation_opts(p, frame = 1000, transition = 500, easing = "linear",
redraw = TRUE, mode = "immediate")
但是,我无法在具有相同数据框的本地运行(不是在闪亮服务器上)的闪亮应用中显示此内容。目前,我的(简化的)闪亮应用是:
library(shiny)
library(ggplot2)
library(plotly)
shinyApp(
shinyUI(
fluidPage(
plotOutput("HF.plot")
)
),
shinyServer(function(input, output, session) {
load("HF.RData")
output$HF.plot <- renderPlotly({
p <- ggplot(dt1.HF, aes(x = tm, y = HF, colour = team)) +
geom_point(aes(frame = sn, ids = tm), size = 5)
p <- ggplotly(p)
animation_opts(p, frame = 1000, transition = 500, easing = "linear",
redraw = TRUE, mode = "immediate")
})
})
)
我有什么遗漏或做错了吗?
【问题讨论】:
-
在
renderPlotly末尾返回p是否有帮助?目前您只返回animation_opts的返回值 -
@thothal 谢谢,我试过了,但同样的问题仍然存在
-
你能创建一个reprex吗?没有手头的数据很难说
标签: r ggplot2 shiny plotly r-plotly