没有垂直线的 3d 散点图
Scatterplot 3d without the vertical lines
我想绘制以下数据的 3 维散点图
structure(list(F = c(18.2108626198083, 2.06349206349206, -15.6842105263158,
10.9896271376507, -0.556328233657855, 12.076929537247, -16.769617936399,
-5.40540540540539, 26.7848350566224, 3.44509736144716, -3.78808674169641,
-3.93232738911752, -17.0253164556962, 50.0781773509046, 12.510897994769,
20.2367901775926, 26.6812295209861, 0.823250592490954, -8.45476109793292,
0.4381988516168, 3.25581395348837, 70.7155195926903, 65.3364908808144,
34.9882618902704, 13.5342789598109, 15.7754010695187, 25.8784621744522,
51.1947779461476, 57.65475695887, 25.3116162145177, 3.82276281494354,
1.79372197309418, 10.2564102564102, 8.47766636280765, -3.43749999999999,
-2.43828101188662, 7.02947845804989, 6.6265060240964, -17.7431906614786,
20.9261635366849, -19.79443353736, -5.68079350766456, -3.64931019136626,
-3.52055681450308, -6.89010606850983, -6.04523785373771, 28.3127758289012,
7.76389909380357, 1.91727321143262, 3.78228782287824, -11.9123325005678,
32.2663618176622, 47.3957158962796, 34.7805642633229, -9.11998349324254,
18.3434354013117, -17.5318341912761, 0.428658909981627, 23.4457537586347,
42.3697650663943, 6.65660170189404, 11.7365833950576, 27.9735682819383,
29.3706293706294, 3.40623879526711, -2.29291468704813, -26.2389149713093,
15.121107266436, -8.24175824175825, -30.518697225573, -7.83855903935958
), D = c(3, 4, 4, 5, 5, 1, 5, 3, 0, 4, 4, 0, 4, 3, 0, 1, 1, 6,
3, 4, 1, 5, 2, 4, 1, 3, 3, 2, 6, 5, 1, 2, 1, 5, 0, 1, 2, 5, 0,
4, 0, 1, 1, 0, 2, 2, 2, 6, 6, 3, 1, 6, 6, 2, 3, 6, 0, 1, 3, 2,
2, 3, 4, 2, 1, 3, 0, 0, 2, 4, 5), C = c(38, 38, 40, 40, 38, 36,
38, 36, 42, 36, 36, 40, 38, 38, 24, 42, 34, 40, 40, 40, 34, 42,
36, 42, 38, 40, 44, 40, 38, 36, 32, 30, 32, 36, 38, 38, 32, 40,
32, 34, 38, 42, 28, 36, 42, 34, 42, 36, 44, 36, 36, 40, 38, 38,
32, 42, 30, 30, 34, 36, 40, 34, 44, 32, 40, 42, 34, 36, 34, 42,
44)), .Names = c("F", "D", "C"), row.names = c("var1", "var2",
"var3", "var4", "var5", "var6", "var7", "var8", "var9", "var10",
"var11", "var12", "var13", "var14", "var15", "var16", "var17",
"var18", "var19", "var20", "var21", "var22", "var23", "var24",
"var25", "var26", "var27", "var28", "var29", "var30", "var31",
"var32", "var33", "var34", "var35", "var36", "var37", "var38",
"var39", "var40", "var41", "var42", "var43", "var44", "var45",
"var46", "var47", "var48", "var49", "var50", "var51", "var52",
"var53", "var54", "var55", "var56", "var57", "var58", "var59",
"var60", "var61", "var62", "var63", "var64", "var65", "var66",
"var67", "var68", "var69", "var70", "var71"), class = "data.frame")
我想要一张如上图所示的图片。我使用如下的 scatterplot3d 包,得到如下图。
with(phos, {
s3d <- scatterplot3d(C,D,F,grid=TRUE, box=TRUE, cex.lab=2,
color="red", cex.main=2,pch=19,main="3D Scatterplot",
ylab="D", xlab="C", zlab="F", type="h"
)})
我想要的是网格出现在其他两个平面中(即我想要网格出现在所有 3 个平面中,X、Y 和 Z)并删除前面的三个(只有那三个)线阴谋。如果我这样做
框=假
在上面的代码中,我得到如下图,它缺少两条垂直线和网格,这不是我想要的。有没有办法解决这个问题。我更喜欢 scatterplot3d 解决方案而不是 rgl,因为 rgl 不使用基本图形。
使用函数 addgrids3d.r()
和 this forum 中发布的源代码,您可以按以下方式绘制数据:
scatterplot3d(phos$C,phos$D,phos$F, color="red", pch = 19, grid=FALSE, box=FALSE, main="3D Scatterplot", cex.main=2,cex.lab=2,ylab="D", xlab="C", zlab="F")
addgrids3d(phos$C,phos$D,phos$F, grid = c("xy", "xz", "yz"))
此图与您想要的不完全相同(C 轴的值向右增加,而在您的图像中它们向左增加),但它包含所需的网格并且没有您要删除的前面的三行。
使用 rgl
可能会获得与您想要的输出更相似的结果。
我想绘制以下数据的 3 维散点图
structure(list(F = c(18.2108626198083, 2.06349206349206, -15.6842105263158,
10.9896271376507, -0.556328233657855, 12.076929537247, -16.769617936399,
-5.40540540540539, 26.7848350566224, 3.44509736144716, -3.78808674169641,
-3.93232738911752, -17.0253164556962, 50.0781773509046, 12.510897994769,
20.2367901775926, 26.6812295209861, 0.823250592490954, -8.45476109793292,
0.4381988516168, 3.25581395348837, 70.7155195926903, 65.3364908808144,
34.9882618902704, 13.5342789598109, 15.7754010695187, 25.8784621744522,
51.1947779461476, 57.65475695887, 25.3116162145177, 3.82276281494354,
1.79372197309418, 10.2564102564102, 8.47766636280765, -3.43749999999999,
-2.43828101188662, 7.02947845804989, 6.6265060240964, -17.7431906614786,
20.9261635366849, -19.79443353736, -5.68079350766456, -3.64931019136626,
-3.52055681450308, -6.89010606850983, -6.04523785373771, 28.3127758289012,
7.76389909380357, 1.91727321143262, 3.78228782287824, -11.9123325005678,
32.2663618176622, 47.3957158962796, 34.7805642633229, -9.11998349324254,
18.3434354013117, -17.5318341912761, 0.428658909981627, 23.4457537586347,
42.3697650663943, 6.65660170189404, 11.7365833950576, 27.9735682819383,
29.3706293706294, 3.40623879526711, -2.29291468704813, -26.2389149713093,
15.121107266436, -8.24175824175825, -30.518697225573, -7.83855903935958
), D = c(3, 4, 4, 5, 5, 1, 5, 3, 0, 4, 4, 0, 4, 3, 0, 1, 1, 6,
3, 4, 1, 5, 2, 4, 1, 3, 3, 2, 6, 5, 1, 2, 1, 5, 0, 1, 2, 5, 0,
4, 0, 1, 1, 0, 2, 2, 2, 6, 6, 3, 1, 6, 6, 2, 3, 6, 0, 1, 3, 2,
2, 3, 4, 2, 1, 3, 0, 0, 2, 4, 5), C = c(38, 38, 40, 40, 38, 36,
38, 36, 42, 36, 36, 40, 38, 38, 24, 42, 34, 40, 40, 40, 34, 42,
36, 42, 38, 40, 44, 40, 38, 36, 32, 30, 32, 36, 38, 38, 32, 40,
32, 34, 38, 42, 28, 36, 42, 34, 42, 36, 44, 36, 36, 40, 38, 38,
32, 42, 30, 30, 34, 36, 40, 34, 44, 32, 40, 42, 34, 36, 34, 42,
44)), .Names = c("F", "D", "C"), row.names = c("var1", "var2",
"var3", "var4", "var5", "var6", "var7", "var8", "var9", "var10",
"var11", "var12", "var13", "var14", "var15", "var16", "var17",
"var18", "var19", "var20", "var21", "var22", "var23", "var24",
"var25", "var26", "var27", "var28", "var29", "var30", "var31",
"var32", "var33", "var34", "var35", "var36", "var37", "var38",
"var39", "var40", "var41", "var42", "var43", "var44", "var45",
"var46", "var47", "var48", "var49", "var50", "var51", "var52",
"var53", "var54", "var55", "var56", "var57", "var58", "var59",
"var60", "var61", "var62", "var63", "var64", "var65", "var66",
"var67", "var68", "var69", "var70", "var71"), class = "data.frame")
我想要一张如上图所示的图片。我使用如下的 scatterplot3d 包,得到如下图。
with(phos, {
s3d <- scatterplot3d(C,D,F,grid=TRUE, box=TRUE, cex.lab=2,
color="red", cex.main=2,pch=19,main="3D Scatterplot",
ylab="D", xlab="C", zlab="F", type="h"
)})
我想要的是网格出现在其他两个平面中(即我想要网格出现在所有 3 个平面中,X、Y 和 Z)并删除前面的三个(只有那三个)线阴谋。如果我这样做
框=假
在上面的代码中,我得到如下图,它缺少两条垂直线和网格,这不是我想要的。有没有办法解决这个问题。我更喜欢 scatterplot3d 解决方案而不是 rgl,因为 rgl 不使用基本图形。
使用函数 addgrids3d.r()
和 this forum 中发布的源代码,您可以按以下方式绘制数据:
scatterplot3d(phos$C,phos$D,phos$F, color="red", pch = 19, grid=FALSE, box=FALSE, main="3D Scatterplot", cex.main=2,cex.lab=2,ylab="D", xlab="C", zlab="F")
addgrids3d(phos$C,phos$D,phos$F, grid = c("xy", "xz", "yz"))
此图与您想要的不完全相同(C 轴的值向右增加,而在您的图像中它们向左增加),但它包含所需的网格并且没有您要删除的前面的三行。
使用 rgl
可能会获得与您想要的输出更相似的结果。