As shown in the image below, the height of my plot remains constant when multiple counties are selected in the sidebar. This makes the plot too crowded so that the labels become unreadable. I would like to alter the height of my plot as a function of the number of counties that are selected in the sidebar. How can I do this?
Below, please see part of my codes that I believe need to be modified.
UI element
mainPanel(plotOutput("workforce_plot"),
server element
workforce_plot <- reactive({
ggplot(workforce_data(), aes(x =Age_Group, y = Percentage, fill=County.y)) +
geom_bar(stat = "identity",position = position_dodge()) +
geom_text(
aes(label = Percentage2),
vjust = 0.5,
colour = "black",
position = position_dodge(width=0.9),
fontface = "bold",
size=3.2,
hjust = 0)+
ylim(0,110)+
coord_flip()+
labs(
x = "Age Groups",
y = "Percentage",
face = "bold")
})
output$workforce_plot <- renderPlot ({
workforce_plot()
})