【问题标题】:Plotting two graphs, one below the other, in shiny panel在闪亮的面板中绘制两张图,一张在另一张下方
【发布时间】:2016-01-17 04:47:27
【问题描述】:

我正在制作两个图表。

现在它们显示在两个不同的面板(标签)中

ui.r
mainPanel(
      tabsetPanel(
        tabPanel("Summary", dataTableOutput("dis")),
        tabPanel("Plot", plotOutput("plot1")),
        tabPanel("Plot", plotOutput("plot2"))
      )
    )

server.r

output$plot1 <- renderPlot({
    Plot1
  })


output$plot2 <- renderPlot({
    Plot1
 })

我想知道如何在同一个面板中显示这些图表,而不是像现在这样的两个不同的面板。谢谢大家帮忙。

【问题讨论】:

  • 对于 ggplot2 绘图,您可以使用 grid.arrange(gplot, gplot, ncol=1)。对于基本图,您可以执行par(mfrow=c(2,1)) ; plot(…) ; plot(…); par(mfrow=c(1,1))

标签: r plot shiny-server shiny


【解决方案1】:

您可以将它们包装在 fluidRow 中,或者将它们列在同一个 tabPanel

shinyApp(
    shinyUI(
        fluidPage(
            mainPanel(
                tabsetPanel(
                    tabPanel("Summary", dataTableOutput("dis")),
                    tabPanel("Plot",
                             # fluidRow(...)
                                 plotOutput("plot1"),
                                 plotOutput("plot2")
                             )
                )
            )
        )
    ),
    shinyServer(function(input, output) {
        output$plot1 <- renderPlot({
            plot(1:10, 1:10)
        })

        output$plot2 <- renderPlot({
            plot(1:10 ,10:1)
        })

        output$dis <- renderDataTable({})
    })
)

将它们包装在 fluidRow 中可以轻松控制单个绘图属性,例如宽度,

tabPanel("Plot",
         fluidRow(
             column(8, plotOutput("plot1")),
             column(12, plotOutput("plot2"))
         ))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    相关资源
    最近更新 更多