更改“ plotOutput”中绘图区域的高度根据数字的数量(自动)闪亮
我在Shiny的服务器部分中具有“ RenderPlot”功能,该功能产生了1到4个数字。 如何根据数字数量(自动)更改闪亮应用程序中的绘图区域的高度? 我的意思是4个数字的高度应大于2个数字的高度。 我在UI部分中使用了Wight =“ Auto”,Height =“ Auto”,但我有错误。因此,我为其分配了一个固定尺寸(高度=“ 800”),但是如果我有1个数字,那将是很大的。如果我有3或4个,它们会变小。 请查看我的代码的一部分:
#UI section
plotOutput("fancyPlot", inline = F, height = "800")
#Server section
output$fancyPlot <- renderPlot({
#I get the plot_list_final which has some plots (1 or 2 or 3 or 4).
n <- lenght(plot_list_final )
nCol <- floor(sqrt(n))
p_last = do.call("grid.arrange", c(plot_list_final, ncol=nCol))
return(p_last)
})
I have a " renderplot " function in the server section of Shiny that produces 1 to 4 figures.
how can I change the height of the plot area in the shiny app based on the number of the figures (automatically)?
I mean the height for 4 figures should be bigger than the height for 2 figures.
I used wight = "auto" , height = "auto" in the UI section but I got error. So I assign a fixed size to it (height = "800"), but if I have 1 figure it would be very big. if I have 3 or 4 they get smaller.
please see a part of my code:
#UI section
plotOutput("fancyPlot", inline = F, height = "800")
#Server section
output$fancyPlot <- renderPlot({
#I get the plot_list_final which has some plots (1 or 2 or 3 or 4).
n <- lenght(plot_list_final )
nCol <- floor(sqrt(n))
p_last = do.call("grid.arrange", c(plot_list_final, ncol=nCol))
return(p_last)
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
grid.arrange
中单独完成每个图,例如fluidPage
stliplaylayout
。在这种情况下,每个图都有单独的数字。在这种情况下,用renderui
生成UI,具有对行数和列的调整功能。这是解决方案:
You can do every plot in your
grid.arrange
individually, for example insidefluidPage
withsplitLayout
. In this case, you have separate figure for each plot. UI is generated withrenderUI
in this case to have capability of adjustment for number of rows and columns.Here is the solution: