如何在R中绘制多个多边形图? [英] how to plot multiple polygon plots in R?

查看:268
本文介绍了如何在R中绘制多个多边形图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R绘制多边形

I am plotting polygon using R

yy<-c(1217,2343,3255,2129)
xx<-c(61587690.5,61588253.5,61587797.5,61587234.5)
polygon(xx, yy, col="gray", border = "red")

但是我想向同一图表添加100000个多边形图.如何将全部添加到一张图表中.

But i want to add 100000 polygon plots to the same chart. How can i add all into one chart.

推荐答案

下面是使用坐标列表列表的示例.它将同一区域中的所有多边形都绘制出来(我想问的是它们对您有多清晰……)

Here's an example using a list of lists of coordinates. It plots all polygons in the same plot (I leave the question of how discernible they are to you...)

#generate some data
set.seed(123)
n=10
#each 'polygon' is inside a list with xx and yy coordinates
dat <- lapply(1:n,function(x){
  res <- list(xx=c(1,2,3,2)+rnorm(4),
              yy=c(1,2,3,2)+rnorm(4))
  return(res)
})

#create empty plot
plot(0:5,0:5,type='n')
#add polygons
lapply(dat,function(x){polygon(x$xx,x$yy,col="gray",border="red")})

这篇关于如何在R中绘制多个多边形图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆