安装maps包
install.packages(“maps”)
加载某个安装的R包:
library(“maps”)
map(“state”, interior = FALSE)
map(“state”, boundary = FALSE, col=“red”, add = TRUE)
map(‘world’, fill = TRUE,col=heat.colors(10))
实验:社交数据可视化
install.packages(“geosphere”)
加载
library(“maps”) library(“geosphere”)
画出美国地图
map(“state”)
画世界地图
map(“world”)
通过设置坐标范围使焦点集中在美国周边,并且设置一些有关颜色
xlim <-c(-171.,-56.)
ylim <-c(12.039321,71.)
map(“world”, col=“#f2f2f2”, fill=TRUE, bg=“white”, lwd=0.05, xlim=xlim, ylim=ylim)
画一条弧线连线,表示社交关系
lat_ca<- 39.
lon_ca<- -121.64062
lat_me<- 45.21300
lon_me<- -68.
inter<- gcIntermediate(c(lon_ca, lat_ca), c(lon_me, lat_me), n=50, addStartEnd=TRUE)
lines(inter)
继续画弧线
lat_tx<- 29.
lon_tx <- -98.
inter2 <- gcIntermediate(c(lon_ca, lat_ca), c(lon_tx, lat_tx), n=50, addStartEnd=TRUE)
lines(inter2, col=“red”)
装载数据
airports <- read.csv(“http://datasets.flowingdata.com/tuts/maparcs/airports.csv", header=TRUE)
flights <- read.csv(”http://datasets.flowingdata.com/tuts/maparcs/flights.csv", header=TRUE, as.is=TRUE)
画出多重联系
map(“world”, col=“#f2f2f2”, fill=TRUE, bg=“white”, lwd=0.05, xlim=xlim, ylim=ylim)
fsub <- flights[flights\(airline == "AA",] <br /> for (j in 1:length(fsub\)airline)) {
air1 <- airports[airports\(iata == fsub[j,]\)airport1,]
air2 <- airports[airports\(iata == fsub[j,]\)airport2,]
inter <- gcIntermediate(c(air1[1,]\(long, air1[1,]\)lat), c(air2[1,]\(long, air2[1,]\)lat), n=100, addStartEnd=TRUE)
lines(inter, col=“black”, lwd=0.8)
}
2025年R语言maps绘图
R语言maps绘图安装 maps 包 install packages maps 加载某个安装的 R 包 library maps map state interior FALSE map state boundary FALSE col red
大家好,我是讯享网,很高兴认识大家。
什么是IOC-
上一篇
2025-03-15 16:55
2025年矩阵的谱(半径)及其性质
下一篇
2025-02-19 13:55

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/21856.html