在R中动态调整ggplot2图形的大小

在R中动态调整ggplot2图形的大小,r,ggplot2,resize,size,shiny,R,Ggplot2,Resize,Size,Shiny,我试过这个: output$plot <- renderPlot({ getPlot() }, width=input$plotX, height=input$plotY) # referring to two numericInput boxes output$plot您可以使用shinny::exprToFunction将反应值包装到函数中 比如说, output$plot <- renderPlot({ getPlot() }, width=exprToFunctio

我试过这个:

output$plot <- renderPlot({
  getPlot()
}, width=input$plotX, height=input$plotY) # referring to two numericInput boxes

output$plot您可以使用
shinny::exprToFunction
将反应值包装到函数中

比如说,

output$plot <- renderPlot({
  getPlot()
}, width=exprToFunction(input$plotX), 
   height=exprToFunction(input$plotY)))

输出$plot完全工作!虽然如果我把它设置得太高,图形会像这样溢出到下一个UI元素中:还有,有没有办法改变分辨率?当绘图设置为太大的尺寸时,它开始看起来很糟糕。。。也许这就是ggplot()调用的工作?我昨天实际上是在为你的问题寻找解决方案,然后我找到了答案。我想您可以修改其容器的CSS溢出属性以避免溢出。;)您好@vocaloidict,您有没有想过如何自定义容器本身的高度以避免情节溢出?您好@XinYin,我使用溢出属性作为参考,但所有这些属性都试图指示如何控制溢出,而我希望容器扩展以适应其内容。