R 在Shining应用程序中缩放绘图输出

R 在Shining应用程序中缩放绘图输出,r,ggplot2,rstudio,shiny,R,Ggplot2,Rstudio,Shiny,我在缩小绘图输出时遇到问题。我所要做的就是稍微缩小ggplot,以便在框中有一点填充 这是我的照片: 这是我想要的图像: 差别很小,但基本上我只想缩小图形。plotOutput中的width参数可用于此目的。然后,您可以将输出包装在具有中心对齐的div中 library(ggplot2) library(shiny) gg <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + theme(panel.background = element

我在缩小绘图输出时遇到问题。我所要做的就是稍微缩小ggplot,以便在框中有一点填充

这是我的照片:

这是我想要的图像:

差别很小,但基本上我只想缩小图形。

plotOutput中的width参数可用于此目的。然后,您可以将输出包装在具有中心对齐的div中

library(ggplot2)
library(shiny)

gg <- ggplot(mtcars, aes(wt, mpg)) + geom_point() +
  theme(panel.background = element_rect(fill = 'grey'))

shinyApp(
  fluidPage(
    plotOutput('plot1'),
    div(
      plotOutput('plot2'),
      style = "padding-right: 10%; padding-left: 10%"
    )
  ),
  function(input, output, session){
    output$plot1 <- renderPlot(gg)
    output$plot2 <- renderPlot(gg)
  }
)

也许有帮助是的,我看到了这一点,但它没有给我我想要的:/我想缩小的不是整个面板,只是ggplot