大部分情况下,我们使用二维的图像就足以展示我们的数据,但是也无法排除在一些特定的情况下,需要将数据在三维空间进行展示,所以今天小编就给大家分享三维图的画法吧~
NO.01:三维点图
1.下载plot3D包并调用
BiocManager::install("plot3D")
library(plot3D)
2.绘制3D图的坐标向量
z <- seq(0, 20, 0.1)
x <- cos(z)
y <- sin(z)

3.绘制三维点图并美化
参数:phi:控制三维图的上下方向,col:点的颜色,pch:点的形状,cex:点放大多少倍,ticktype:坐标轴的刻度,bty:表示边框类型
scatter3D(x, y, z,
phi = 1,
col = ramp.col(col = c("cyan", "blue"),
n = length(z)),pch =18,
cex = 1,
ticktype = "detailed",bty = "b2")

NO.02:三维线图
1.下载plot3D包并调用
BiocManager::install("plot3D")
library(plot3D)
2.绘制3D图的坐标向量
z <- seq(0, 20, 0.1)
x <- cos(z)
y <- sin(z)

3.绘制三维线图并美化
scatter3D(x, y, z,
phi = 2, type = "l",
col = ramp.col(col=c("cyan","red"),
n=length(z)),ticktype = "detailed",
lwd = 2, bty = "g")

NO.03:三维点线图
1.下载plot3D包并调用
BiocManager::install("plot3D")
library(plot3D)
2.绘制3D图的坐标向量
z <- seq(0, 20, 0.1)
x <- cos(z)
y <- sin(z)

3.绘制三维点线图,type = "b"表示both,即点连线,bty指定边框类型
scatter3D(x, y, z,
phi = 2, type = "b",
col = ramp.col(col=c("cyan","magenta"),
n=length(z)),bty = "f",
ticktype = "detailed",
pch = 15,
cex = c(0.5, 1, 1.5))

网友评论