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