Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny Chart Space Allocation

Tags:

r

shiny

The example below plots 4 groups in 4 panes together. But the problem is that they seem to be residing in a single grid. Is it possible to control the size of the charts in shiny output? (ie so that there is no scroll bar on the right when the app is run) I tried to control the height and width, but that only seems to control the image within the grid itself... any ideas?

thanks

shinyUI(pageWithSidebar(
  headerPanel("Example"),
  sidebarPanel(   

  ),

  mainPanel(
    tabsetPanel(tabPanel("Main",plotOutput("temp"))

    )#tabsetPanel  

  )#mainPane;

))



shinyServer(function(input, output) {

  output$temp <-renderPlot({
     par(mfrow=c(2,2))
     plot(1:10)
     plot(rnorm(10))
     plot(rnorm(10))
     plot(rnorm(10))
  }, height = 1000, width = 1000)


})
like image 620
user1234440 Avatar asked Jun 20 '13 03:06

user1234440


1 Answers

plotOutput has height and width parameters as well; the width defaults to "100%" (meaning 100% of the available width in its container) and the height defaults to "400px" (400 pixels). Try experimenting with these values, changing them to either "auto" or "1000px".

renderPlot's height and width parameters control the size of the generated image file in pixels, but doesn't directly affect the rendered size in the web page. Their default values are both "auto", which means, detect and use the width/height of the corresponding plotOutput. So once you've set the width and height on plotOutput, you generally don't need the width and height to be set on renderPlot at all.

shinyUI(pageWithSidebar(
  headerPanel("Example"),
  sidebarPanel(   

  ),

  mainPanel(
    tabsetPanel(tabPanel("Main",plotOutput("temp", height = 1000, width = 1000))

    )#tabsetPanel  

  )#mainPane;

))



shinyServer(function(input, output) {

  output$temp <-renderPlot({
     par(mfrow=c(2,2))
     plot(1:10)
     plot(rnorm(10))
     plot(rnorm(10))
     plot(rnorm(10))
  })


})
like image 138
Joe Cheng Avatar answered Nov 18 '22 09:11

Joe Cheng