R语言中geom_polygon在绘图区域截取任意形状、填色(多边形)

 

001、

# 创建一个多边形
df <- data.frame(
  x = c(1, 2, 2, 1, 1.26),
  y = c(1, 1, 2, 1.6, 1.26)
)
df
# 绘制多边形
ggplot() +
  geom_polygon(data = df, aes(x = x, y = y),
               fill = "green", colour = "black", alpha)      ## 绘图结果

 

。 

 

posted @ 2024-06-03 17:18  小鲨鱼2018  阅读(31)  评论(0编辑  收藏  举报