Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

r - Shiny Chart Space Allocation

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)


})
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...