使用闪亮时不显示 Plotly plot
Plotly plot doesn't show up when using shiny
我正在尝试绘制带有滑块的热图。滑块显示但 plotly 热图没有。当不与 shiny 一起使用时,热图绘制得很好。有一次我让代码可以工作,但后来我把它弄坏了,我不知道怎么做。
library(gplots)
library(plotly)
library(shiny)
#Ui
ui <- fluidPage(
titlePanel("Example"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "P4Volume",
label = "Example:",
min = 50000,
max = 1200000,
value = 30)
),
mainPanel(
plotlyOutput(outputId = "heatmap"),
)
)
)
#Server
server <- function(input, output) {
output$heatmap <- renderPlotly({
*Code here that takes input$P4Volume and creates a matrix z
plot_ly(z,x,y,type= "heatmap",width=800,height=600)
})
}
shinyApp(ui, server)
我什至尝试了一个非常简单的例子,没有滑块,只有情节图:
library(shiny)
library(plotly)
x=seq(0,10,2)
y=seq(0,10,2)
z=matrix(100,nrow=6,ncol=6)
p=plot_ly(z=z, x = x, y =y,type="heatmap")
ui <- fluidPage(
plotlyOutput("plot")
)
server <- function(input, output) {
output$plot <- renderPlotly({p})
}
shinyApp(ui, server)
而且我仍然没有得到一个 plotly 热图,但是当我在 shinny 之外绘制它时,它绘制得很好......
原来它在 chrome 中有效,但在 IE 中无效。将我在 R 中的浏览器更改为 chrome,现在一切看起来都很好!
我正在尝试绘制带有滑块的热图。滑块显示但 plotly 热图没有。当不与 shiny 一起使用时,热图绘制得很好。有一次我让代码可以工作,但后来我把它弄坏了,我不知道怎么做。
library(gplots)
library(plotly)
library(shiny)
#Ui
ui <- fluidPage(
titlePanel("Example"),
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "P4Volume",
label = "Example:",
min = 50000,
max = 1200000,
value = 30)
),
mainPanel(
plotlyOutput(outputId = "heatmap"),
)
)
)
#Server
server <- function(input, output) {
output$heatmap <- renderPlotly({
*Code here that takes input$P4Volume and creates a matrix z
plot_ly(z,x,y,type= "heatmap",width=800,height=600)
})
}
shinyApp(ui, server)
我什至尝试了一个非常简单的例子,没有滑块,只有情节图:
library(shiny)
library(plotly)
x=seq(0,10,2)
y=seq(0,10,2)
z=matrix(100,nrow=6,ncol=6)
p=plot_ly(z=z, x = x, y =y,type="heatmap")
ui <- fluidPage(
plotlyOutput("plot")
)
server <- function(input, output) {
output$plot <- renderPlotly({p})
}
shinyApp(ui, server)
而且我仍然没有得到一个 plotly 热图,但是当我在 shinny 之外绘制它时,它绘制得很好......
原来它在 chrome 中有效,但在 IE 中无效。将我在 R 中的浏览器更改为 chrome,现在一切看起来都很好!