是否可以将 Shiny 中的行的大小减小到一定高度以上

Is it possible to decrease size of a row in Shiny beyond a certain height

我喜欢调整行高,以便布局“侧边栏面板加主面板(2 行 X 2 列)”填充浏览器的可用区域window, 因此它允许在不向下滚动页面的情况下可视化所有数字。

在默认选项下,需要向下滚动页面才能完全看到第二行。为了解决这个问题,我在“renderPlot”中使用了“height”[即height=200]以及“”中的“样式”[即div(style = "height:100px") ]。 height' 在 renderplot 中减小了绘图大小,并且行高随高度值的变化而变化 'div(style = "height:100px")',但是大约@height:70px行高是固定的;即使像素数量减少,行高也没有进一步降低; hr() 绘制了一条水平线,它给出了 style[ 中 height 的不同值行高如何变化的想法。问题是,在这个最低值下,底部图需要向下滚动页面,而我希望“sidebar panel plus main panel (with multiple rows)”位于浏览器的可用区域window 这样我就不需要向下滚动页面了。非常感谢您的帮助。

以下链接在一定程度上很有用:

Control the height in fluidRow in R shiny and Scale and size of plot in RStudio shiny

这里是生成sidebar panel plus main panel of 2 X 1的示例代码:

library(shiny)
library(ggplot2)

ui<- pageWithSidebar(
  headerPanel('data:Iris'),
  sidebarPanel(
    selectInput('xcol', 'X Variable', names(iris)),
    selectInput('ycol', 'Y Variable (Plot 1)', names(iris),
                selected=names(iris)[[2]]),
    selectInput('ycol2', 'Y Variable (Plot 2)', names(iris),
                selected=names(iris)[[3]])
  ),
  mainPanel(
    fluidRow(
      column(6,plotOutput('plot1'),div(style = "height:100px"))
    ),
    hr(),
    fluidRow(
      column(6,plotOutput('plot2'))
    )
  )
)

server <- function(input, output) {

  # pass data of selected input variables from the dataframe to ggplot

  # Plot 1
  output$plot1 <- renderPlot({
    ggplot(iris,aes_string(input$xcol,input$ycol))+geom_point()
  },height = 200)

  # Plot 2
  output$plot2 <- renderPlot({
    ggplot(iris,aes_string(input$xcol,input$ycol2))+geom_point()
  },height = 200)
}

shinyApp(ui =ui, server = server)

如此处所示,第二行中的绘图需要向下滚动网页才能完整查看。

实际上是 plotOutput 默认高度为“400px”。将行更改为

column(6,plotOutput('plot1', height="200px"))