眨眼ggplot在闪亮的R应用程序
问题描述:
我正在做一个小闪亮的应用程序,只有一个ggplot每隔几秒更新一次。它有效,但闪烁有点烦人。我想知道有没有人有关于如何平滑的想法。例如:眨眼ggplot在闪亮的R应用程序
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的第一个项目。这似乎不适用于我的情况。
何种操作系统和网络浏览器您使用?在RStudio 0.99.491,Chrome 52.0.2743.116或Firefox ESR 45.3.0的Debian 8机器上,我没有看到任何“闪烁”。 (R 3.31,ggplot2_2.2.1,shiny_0.13.0) – Peter
啊我没有想到这一点。 WIndows 10,Firefox 48.0,ggplot2_2.1.0 shiny_0.12.2,R版本3.2.2。它在firefox中闪烁,但不在Chrome 52.0.2743.116中。 HMN –