【问题标题】:Shiny Chart Space Allocation闪亮的图表空间分配
【发布时间】:2013-06-16 18:49:16
【问题描述】:

下面的示例将 4 个窗格中的 4 个组绘制在一起。但问题是它们似乎位于一个网格中。是否可以控制闪亮输出中图表的大小? (即,当应用程序运行时右侧没有滚动条)我试图控制高度和宽度,但这似乎只能控制网格本身内的图像......有什么想法吗?

谢谢

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)


})

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    plotOutput 也有高度和宽度参数;宽度默认为"100%"(表示其容器中可用宽度的100%),高度默认为"400px"(400 像素)。尝试使用这些值进行试验,将它们更改为 "auto""1000px"

    renderPlot 的高度和宽度参数控制生成的图像文件的大小(以像素为单位),但不直接影响网页中呈现的大小。它们的默认值都是"auto",即检测并使用对应plotOutput的宽度/高度。因此,一旦您在plotOutput 上设置了宽度和高度,您通常根本不需要在renderPlot 上设置宽度和高度。

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

    【讨论】:

    • 如果我有navbarPage 控制输出,因此我没有plotOutput 可以操作,我该怎么办? stackoverflow.com/questions/30179621/…
    • 谢谢乔,auto 现在似乎不太好用。使用 plotOutput("screenplot", width = "100%", height = "auto") 并且 Chrome 中没有显示图表。我在帮助中看到它指出 “请注意,对于高度,使用“auto”或“100%”通常不会按预期工作,因为如何使用 HTML/CSS 计算高度”现在推荐除了固定高度吗?谢谢
    猜你喜欢
    • 2021-09-26
    • 1970-01-01
    • 2019-02-18
    • 1970-01-01
    • 2021-06-18
    • 2020-12-26
    • 2020-10-16
    • 1970-01-01
    • 2016-08-15
    相关资源
    最近更新 更多