【发布时间】:2023-03-16 15:43:01
【问题描述】:
在这个闪亮的应用程序中,如果我们选择第二个单选按钮“在同一图上显示图”,我希望在同一图上显示两个图 提前感谢您的帮助
library(shiny)
library(plotly)
ui <-fluidPage(
titlePanel("title panel"),
sidebarLayout(position = "left",
sidebarPanel(
radioButtons(inputId = "plot", label=' ', choices=c("display plots on separate figures", "display plots on the same figure"))
),
mainPanel(
plotlyOutput(outputId = "fbPlot1"),
plotlyOutput(outputId = "fbPlot2")
)
))
server <- function(input, output) {
output$fbPlot1 <- renderPlotly(
fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
)
output$fbPlot2 <- renderPlotly(
fig2 <- plot_ly(data = iris, x = ~Petal.Length, y = ~Sepal.Length,color ='blue')
)
}
shinyApp(ui = ui, server = server)
【问题讨论】: