[R] RGL 3D plots are flat. Please Help

Noah Silverman noahsilverman at ucla.edu
Tue Mar 19 02:21:54 CET 2013


Hello,

I have a matrix of simulated data that I want to plot as a 3D surface using RGL.  Have followed the documentation carefully, but my plot only contains a weird "single slice" of the data.  

The actual RGL library and dependance seem fine as all of the demo code plots beautifully.

The actual command I'm using is:  rgl.surface(x,z,d, color="blue",alpha=0.5,shininess=128)

The length of the x and z vectors match the dimensions of the y matrix.  

Can't figure out why I'm only getting a "slice" and not a full 3D surface.

Without digging into too much detail, here is what my data looks like.

x
 [1]    0  100  200  300  400  500  600  700  800  900 1000 1100 1200 1300 1400 1500
[17] 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500

z
 [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
[21] 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0

y (Only first bit included here.)
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
 [1,]    0    0    0    0    0    0    0    0    0     0     0     0     0     0
 [2,]    0    2    3    5    6    8   10   11   13    14    16    18    19    21
 [3,]    0    3    6   10   13   16   19   22   26    29    32    35    38    42
 [4,]    0    5   10   14   19   24   29   34   38    43    48    53    58    62
 [5,]    0    6   13   19   26   32   38   45   51    58    64    70    77    83
 [6,]    0    8   16   24   32   40   48   56   64    72    80    88    96   104
 [7,]    0   10   19   29   38   48   58   67   77    86    96   106   115   125
 [8,]    0   11   22   34   45   56   67   78   90   101   112   123   134   146
 [9,]    0   13   26   38   51   64   77   90  102   115   128   141   154   166
[10,]    0   14   29   43   58   72   86  101  115   130   144   158   173   187
[11,]    0   16   32   48   64   80   96  112  128   144   160   176   192   208
[12,]    0   18   35   53   70   88  106  123  141   158   176   194   211   229
[13,]    0   19   38   58   77   96  115  134  154   173   192   211   230   250
[14,]    0   21   42   62   83  104  125  146  166   187   208   229   250   270
[15,]    0   22   45   67   90  112  134  157  179   202   224   246   269   291
[16,]    0   24   48   72   96  120  144  168  192   216   240   264   288   312
[17,]    0   26   51   77  102  128  154  179  205   230   256   282   307   333
[18,]    0   27   54   82  109  136  163  190  218   245   272   299   326   354
[19,]    0   29   58   86  115  144  173  202  230   259   288   317   346   374
[20,]    0   30   61   91  122  152  182  213  243   274   304   334   365   395
[21,]    0   32   64   96  128  160  192  224  256   288   320   352   384   416
[22,]    0   34   67  101  134  168  202  235  269   302   336   370   403   437
[23,]    0   35   70  106  141  176  211  246  282   317   352   387   422   458
[24,]    0   37   74  110  147  184  221  258  294   331   368   405   442   478
[25,]    0   38   77  115  154  192  230  269  307   346   384   422   461   499
[26,]    0   40   80  120  160  200  240  280  320   360   400   440   480   520


--
Noah Silverman, M.S.
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095



More information about the R-help mailing list