在R中使用线框显示3D

时间:2014-03-20 20:36:44

标签: r 3d plot

我正在尝试使用Wireframe在R中绘制3D图形,但是我在正确显示图形时遇到了问题。数据如下:

 [1,]    1 1.000000    1
 [2,]    2 1.709133    1
 [3,]    4 3.278188    1
 [4,]    8 5.082078    1
 [5,]   16 5.753403    1
 [6,]   32 5.778228    1
 [7,]   64 5.783567    1
 [8,]    1 1.000000    2
 [9,]    2 1.709133    2
[10,]    4 3.278429    2
[11,]    8 5.081508    2
[12,]   16 5.751819    2
[13,]   32 5.777714    2
[14,]   64 5.783520    2
[15,]    1 1.000000    3
[16,]    2 1.709133    3
[17,]    4 3.278632    3
[18,]    8 5.079604    3
[19,]   16 5.753117    3
[20,]   32 5.777558    3
[21,]   64 5.783742    3
[22,]    1 1.000000    4
[23,]    2 1.709133    4
[24,]    4 3.278708    4
[25,]    8 5.080512    4
[26,]   16 5.753243    4
[27,]   32 5.778988    4
[28,]   64 5.782796    4
[29,]    1 1.000000    5
[30,]    2 1.709133    5
[31,]    4 3.278253    5
[32,]    8 5.082100    5
[33,]   16 5.752612    5
[34,]   32 5.778187    5
[35,]   64 5.783359    5
[36,]    1 1.000000    6
[37,]    2 1.709133    6
[38,]    4 3.278576    6
[39,]    8 5.078772    6
[40,]   16 5.753112    6
[41,]   32 5.777878    6
[42,]   64 5.784069    6
[43,]    1 1.000000    7
[44,]    2 1.709133    7
[45,]    4 3.277898    7
[46,]    8 5.081783    7
[47,]   16 5.753860    7
[48,]   32 5.777794    7
[49,]   64 5.784079    7
[50,]    1 1.000000    8
[51,]    2 1.709133    8
[52,]    4 3.278517    8
[53,]    8 5.080553    8
[54,]   16 5.750771    8
[55,]   32 5.779782    8
[56,]   64 5.783110    8
[57,]    1 1.000000    9
[58,]    2 1.709133    9
[59,]    4 3.278196    9
[60,]    8 5.080629    9
[61,]   16 5.753407    9
[62,]   32 5.777428    9
[63,]   64 5.784100    9
[64,]    1 1.000000   10
[65,]    2 1.709133   10
[66,]    4 3.278395   10
[67,]    8 5.081113   10
[68,]   16 5.752613   10
[69,]   32 5.777564   10
[70,]   64 5.783312   10

我尝试了以下代码:

 wireframe(temp, scales = list(arrows = FALSE,
 x = list(labels = 2^seq(0, 6)),  
 y = list(labels = seq(1,7)),
 z = list (labels =seq(1,7))), drape = TRUE, colorkey = TRUE,
 screen = list(z = 30, x = -60),
xlab = "X", ylab = "Y", zlab = "Z")

我不知道为什么图表显示如下: enter image description here

如果我尝试为前7行显示相同的代码,那么数字就是这样: enter image description here

任何人都知道这是什么问题?

1 个答案:

答案 0 :(得分:2)

我认为你需要在这里使用aspect参数。

wireframe(as.matrix(dat), 
          scales = list(arrows = FALSE, x = list(labels = 2^seq(0, 6)),  
                        y = list(labels = seq(1,7)), z = list(labels =seq(1,7))),
          drape = TRUE, colorkey = TRUE, aspect = c(61/87, 0.4), 
          screen = list(z = 30, x = -60), xlab = "X", ylab = "Y", zlab = "Z")

enter image description here