R语言可视化(三)

可视化投影

可视化百度云资料连接为:
链接:https://pan.baidu.com/s/1WHIKNx3VOIboHt0YjDYdbQ
提取码:hqxt

投影方式一

install.packages("plot3D")
install.packages("fields")
library(plot3D)

# Reference:https://github.com/coconn/cso002code_BrazilTradeOffsR

par(mfrow = c(1, 1))
panelfirst <- function(pmat) {
  zmin <- min(-quakes$depth)
  XY <- trans3D(quakes$long, quakes$lat,
                z = rep(zmin, nrow(quakes)), pmat = pmat)
  scatter2D(XY$x, XY$y, col = "black", pch = ".",
            cex = 2, add = TRUE, colkey = FALSE)
  xmin <- min(quakes$long)
  XY <- trans3D(x = rep(xmin, nrow(quakes)), y = quakes$lat,
                z = -quakes$depth, pmat = pmat)
  scatter2D(XY$x, XY$y, col = "black", pch = ".",
            cex = 2, add = TRUE, colkey = FALSE)
}


library(scales)
library(RColorBrewer)
library(fields) 
colormap <- colorRampPalette(rev(brewer.pal(11,'RdYlGn')))(100)#

index <- ceiling(((prc <- 0.7 * quakes$mag/ diff(range(quakes$mag))) - min(prc) + 0.3)*100)
for (i in seq(1,length(index)) ){
  prc[i]=colormap[index[i]]
}


pmar <- par(mar = c(5.1, 4.1, 4.1, 6.1))
with(quakes, scatter3D(x = long, y = lat, z = -depth, #bgvar = mag,
                       pch = 21, cex = 1.5,col="black",bg=prc,
                       xlab = "longitude", ylab = "latitude",
                       zlab = "depth, km", 
                       ticktype = "detailed",#bty = "f",box = TRUE,
                       panel.first = panelfirst,
                       theta = 140, phi = 20, d=1.5,
                       colkey = FALSE)#list(length = 0.5, width = 0.5, cex.clab = 0.75))
)
colkey (col=colormap,clim=range(quakes$mag),clab = "Richter", add=TRUE, length=0.5,side = 4)

在这里插入图片描述

投影方式二

pmar <- par(mar = c(5.1, 4.1, 4.1, 6.1))
with(quakes, scatter3D(x = long, y = lat, z = -depth, #bgvar = mag,
pch = 21, cex = 1.5,col=“black”,bg=prc,
xlab = “longitude”, ylab = “latitude”,
zlab = “depth, km”,
ticktype = “detailed”,bty = “f”,box = TRUE,
panel.first = panelfirst,
theta = 140, phi = 20, d=3,
colkey = FALSE)#list(length = 0.5, width = 0.5, cex.clab = 0.75))
)
colkey (col=colormap,clim=range(quakes$mag),clab = “Richter”, add=TRUE, length=0.5,side = 4)

#--------------------------------------------------------------------

投影方式三

pmar <- par(mar = c(5.1, 4.1, 4.1, 6.1))
with(quakes, scatter3D(x = long, y = lat, z = -depth, #bgvar = mag,
                       pch = 21, cex = 1.5,col="black",bg=prc,
                       xlab = "longitude", ylab = "latitude",
                       zlab = "depth, km", 
                       ticktype = "detailed",#bty = "f",box = TRUE,
                       panel.first = panelfirst,
                       theta = 140, phi = 20, d=30,
                       colkey = FALSE)#list(length = 0.5, width = 0.5, cex.clab = 0.75))
)
colkey (col=colormap,clim=range(quakes$mag),clab = "Richter", add=TRUE, length=0.5,side = 4)

在这里插入图片描述

参考资料1:https://github.com/EasyChart/Beautiful-Visualization-with-R/

参考资料2:https://blog.csdn.net/tandelin/article/details/87719623

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值