[英]Blinking ggplot in shiny R app
我正在做一个小巧的应用,只有一个ggplot,每隔几秒更新一次。 它有效,但眨眼有点烦人。 我想知道是否有人知道如何解决它。 例:
library(shiny)
library(ggplot2)
server <- shinyServer(function(input, output, session) {
output$showplot <- renderPlot({
grid <- expand.grid(1:3,1:3)
nums <- rbinom(9,1,0.5)
g <- ggplot(grid,aes(Var1,Var2)) +
geom_tile(aes(fill = nums),colour="black") +
guides(fill = FALSE) +
theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) +
theme(aspect.ratio=1)
print(g)
invalidateLater(1000,session)
})
})
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
),
mainPanel(
h5("Plot blinking"),
plotOutput("showplot")
)
)
))
runApp(list(ui = ui, server = server))
我应该补充一点,在寻找类似的问题时,提供的解决方案是添加
tags$style(type="text/css",
".recalculating {opacity: 1.0;}" ),
作为FluidPage中的第一项。 这对我的情况似乎不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.