0

我在 RShiny 中使用带有 geom_tile 的 ggplot 图表。当我选择 y 轴元素较少的类别时,图块的高度会增加。我想修复磁贴高度,以便在 y 轴元素较少时图表高度降低,代码如下:

 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")
4

0 回答 0