I'm using a ggplot chart with geom_tile in RShiny. When I select a category with fewer y-axis elements, the tiles increase in height. I'd like to fix the tile height so that the chart height decreases when there are fewer y-axis elements, code below:
ggplot(selected_data(), aes(week, zone, fill= value, text=text)) +
scale_y_discrete(limits = unique(rev(selected_data()$zone))) +
geom_tile(aes(fill = value)) +
geom_text(aes(label = format(round_half_up(value,digits = 1), nsmall = 1)), size=4) +
labs(x="Week", y="") +
scale_x_discrete(position = "top") +
scale_fill_viridis(option = "viridis") +
theme_grey(base_size = 16) + labs(fill = "Rate per\n1,000 population") +
theme(legend.position = "top")