1
我有x,y和z數據的獨特組合,並且想要創建3d散點圖和曲面圖。 三維散點圖中使用此代碼的工作:如何創建3D表面圖
s3d <-scatterplot3d(x,z,y, pch=16, highlight.3d=TRUE, type="h", main="3D Scatterplot")
但我無法創建使用基本圖形的表面圖。 persp(x, z, y)
給了我錯誤信息:「預計會增加'x'和'y'值。
我也試過RGL包RGL包:
require(rgl)
surface3d(x, y, z)
這導致「錯誤在rgl.surface(X = C(1,1,1,1,1,1,1,1 ,1,1,2,2,2,2,2,! Y軸長度= x行* Z的cols」
我已經看過以前的帖子here也here,但最需要的一些改動或插我怎樣才能用樣本數據創建一個3d曲面圖而不會改變/改變內容的大小
採樣數據如下:
dput(df)
structure(list(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), z = c(1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10), y = c(0.300000041723251, 0.400000065565109,
0.499999970197678, 0.600000023841858, 0.700000047683716, 0.800000071525574,
1.20000004768372, 1.59999990463257, 1.99999988079071, 2.39999985694885,
1.40000009536743, 1.60000002384186, 1.79999983310699, 1.99999988079071,
2.19999980926514, 2.39999985694885, 3, 3.59999990463257, 4.19999980926514,
4.79999971389771, 2.49999976158142, 2.79999971389771, 3.09999990463257,
3.39999961853027, 3.69999980926514, 4, 4.79999971389771, 5.59999990463257,
6.39999961853027, 7.19999980926514, 3.59999990463257, 4, 4.39999961853027,
4.79999971389771, 5.19999980926514, 5.59999990463257, 6.59999990463257,
7.59999942779541, 8.60000038146973, 9.60000038146973, 4.69999980926514,
5.19999980926514, 5.69999980926514, 6.19999980926514, 6.69999980926514,
7.19999980926514, 8.40000057220459, 9.60000038146973, 10.8000011444092,
12.0000009536743)), datalabel = "", time.stamp = "19 Dec 2013 17:54", .Names = c("x",
"z", "y"), formats = c("%9.0g", "%9.0g", "%9.0g"), types = c(254L,
254L, 254L), val.labels = c("", "", ""), var.labels = c("", "",
""), version = 12L, row.names = c("1", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17",
"18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28",
"29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"
), class = "data.frame")