Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 502
Bridgeport Byron Tucker Avatar asked Oct 18 '15 23:10

Bridgeport Byron Tucker


1 Answers

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"))
         ))
like image 148
Rorschach Avatar answered Nov 16 '22 01:11

Rorschach