绘制重叠矩形

Plot overlapping rectangles

我有一个如下所示的数据集:

x, y, width, height
10,20,30,30
11,25,35,30

有什么方法可以在 R 中创建矩形区域的简单热图吗?
就像下图(或类似的东西):

您可以使用 ggplot2 包和 geom_rect 层(用 xminxmaxyminymax 指定角)。

library(ggplot2)
ggplot(data, aes(xmin = x, xmax = x + width,
                 ymin = y, ymax = y + height)) +
    geom_rect(color = NA, fill = "grey", alpha = 0.4) +
    theme_void() +
    theme(plot.background = element_rect(fill = "black"))