Showing posts with label Three-dimensional graph. Show all posts
Showing posts with label Three-dimensional graph. Show all posts

Wednesday, October 19, 2016

R (programming language): 3D Scatter Plot Example

Command:

> library(scatterplot3d)


Result:

 library(scatterplot3d) でエラー:
   ‘scatterplot3d’ という名前のパッケージはありません


Command:

> install.packages("scatterplot3d")


Result:

 パッケージを ‘/usr/local/lib/R/3.3/site-library’ 中にインストールします
 (‘lib’ が指定されていないため)
 --- このセッションで使うために、CRAN のミラーサイトを選んでください ---
HTTPS CRAN mirror

 1: 0-Cloud [https]                 2: Algeria [https]            
 3: Australia (Melbourne) [https]   4: Australia (Perth) [https]  
 5: Austria [https]                 6: Belgium (Ghent) [https]    
 7: Brazil (RJ) [https]             8: Brazil (SP 1) [https]      
 9: Bulgaria [https]               10: Canada (MB) [https]        
11: Chile [https]                  12: China (Beijing) [https]    
13: China (Hefei) [https]          14: Colombia (Cali) [https]    
15: Czech Republic [https]         16: Denmark [https]            
17: France (Lyon 1) [https]        18: France (Lyon 2) [https]    
19: France (Marseille) [https]     20: France (Montpellier) [https]
21: France (Paris 2) [https]       22: Germany (Falkenstein) [https]
23: Germany (Münster) [https]      24: Iceland [https]            
25: India [https]                  26: Ireland [https]            
27: Italy (Padua) [https]          28: Japan (Tokyo) [https]      
29: Malaysia [https]               30: Mexico (Mexico City) [https]
31: New Zealand [https]            32: Norway [https]              
33: Philippines [https]            34: Russia (Moscow) [https]    
35: Serbia [https]                 36: Spain (A Coruña) [https]    
37: Spain (Madrid) [https]         38: Switzerland [https]        
39: Taiwan (Chungli) [https]       40: Turkey (Denizli) [https]    
41: UK (Bristol) [https]           42: UK (Cambridge) [https]      
43: UK (London 1) [https]          44: USA (CA 1) [https]          
45: USA (IA) [https]               46: USA (KS) [https]            
47: USA (MI 1) [https]             48: USA (TN) [https]            
49: USA (TX) [https]               50: USA (WA) [https]            
51: (HTTP mirrors)                

Selection:


Entered value:

28


Result:

 URL 'https://cran.ism.ac.jp/src/contrib/scatterplot3d_0.3-37.tar.gz' を試しています
Content type 'application/x-gzip' length 585767 bytes (572 KB)
==================================================
downloaded 572 KB

 起動準備中です -  警告メッセージ:
1: Setting LC_TIME failed, using "C"
2: Setting LC_MESSAGES failed, using "C"
3: Setting LC_MONETARY failed, using "C"
* installing *source* package ‘scatterplot3d’ ...
**  パッケージ ‘scatterplot3d’ の解凍および MD5 サムの検証に成功しました
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
 起動準備中です -  警告メッセージ:
1: Setting LC_TIME failed, using "C"
2: Setting LC_MESSAGES failed, using "C"
3: Setting LC_MONETARY failed, using "C"
* DONE (scatterplot3d)

 ダウンロードされたパッケージは、以下にあります
  ‘/private/var/folders/hh/0h10rfgn6vx07dqp8b7lv1700000gn/T/RtmpJRyDyQ/downloaded_packages’


Command:

> library(scatterplot3d)
> attach(mtcars)
> scatterplot3d(wt,disp,mpg,main="3D Scatterplot")


Result:

R 3D Scatter Plot

Command:

> wt


Result:

 [1] 2.620 2.875 2.320 3.215 3.440 3.460 3.570 3.190 3.150 3.440 3.440 4.070
[13] 3.730 3.780 5.250 5.424 5.345 2.200 1.615 1.835 2.465 3.520 3.435 3.840
[25] 3.845 1.935 2.140 1.513 3.170 2.770 3.570 2.780


Command:

> disp


Result:

 [1] 160.0 160.0 108.0 258.0 360.0 225.0 360.0 146.7 140.8 167.6 167.6 275.8
[13] 275.8 275.8 472.0 460.0 440.0  78.7  75.7  71.1 120.1 318.0 304.0 350.0
[25] 400.0  79.0 120.3  95.1 351.0 145.0 301.0 121.0


Command:

> mpg


Result:

 [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4
[16] 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7
[31] 15.0 21.4