Plotting two graphs, one below the other, in shiny panel

23,575

You can wrap them in a fluidRow or just list them inside the same 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({})
    })
)

Wrapping them in a fluidRow provides easy control over individual plot attributes like widths for example,

tabPanel("Plot",
         fluidRow(
             column(8, plotOutput("plot1")),
             column(12, plotOutput("plot2"))
         ))
Share:
23,575
Bridgeport Byron Tucker
Author by

Bridgeport Byron Tucker

Updated on July 14, 2022

Comments

  • Bridgeport Byron Tucker
    Bridgeport Byron Tucker almost 2 years

    I am producing two graphs.

    Right now they are showing up in two different panels (tabs)

    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
     })
    

    I am wondering how can i show these graphs one below the other in the same panel, and not two different panels like how it is now. Thanks folks for helping.