2016-04-28 57 views
1

私は、例えばhereのようにrglライブラリを使って私のplot3dプロットに3D矢印を描きたいと思います。 しかし、どうやら??arrows3Dリターンとして、パッケージの一部ではない、それは推奨されませんまたは将来の音楽arrows3d:現時点で唯一のR-鍛造で利用可能パッケージに基づいて3Dで矢印を描くrgl

No vignettes or demos or help files found with alias or concept or title matching ‘arrows3D’ using fuzzy matching. 
+0

を使用する 'arrows3D'は**組成**パッケージ内の関数です。 ** heplots **パッケージで 'arrow3d'を見ることもできます。 –

+0

参照してくださいhttp://stackoverflow.com/questions/36875133/visulize-a-3d-vector-in-r/36875423#36875423 – lukeA

+0

おかげで! – raumkundschafter

答えて

2

最新rgl(バージョン0.95.1470、;のためのHow do I install the latest version of rgl?を見ますそれを得る方法)はheplots::arrow3d関数の後にモデル化された関数arrow3d()を持っていますが、かなり拡張されています。

heplotsのように(線分で構成された)矢印を描くことも、平坦なポリゴンとして描くことも、ポリゴンの押し出しやポリゴンの回転として描くこともできます。この出力を生成

xyz <- matrix(rnorm(300), ncol = 3) 
plot3d(xyz) 
arrow3d(xyz[1,], xyz[2,], type = "extrusion", col = "red") 
arrow3d(xyz[3,], xyz[4,], type = "flat",  col = "blue") 
arrow3d(xyz[5,], xyz[6,], type = "rotation", col = "green") 
arrow3d(xyz[7,], xyz[8,], type = "lines",  col = "black") 
arrow3d(spriteOrigin = xyz[9:12,],   col = "purple") 

arrow3d example

通常、それは呼び出しごとに1つの矢印を描画していますが、purpleのように(3Dスプライトを求める場合?arrow3dヘルプの例では、現在これを行います例えば、同じ矢印の複数のコピーを描くことができます。

1

matlibパッケージhttps://cran.r-project.org/package=matlibには、(x、y、z)座標の行列を取り、それぞれに矢印を描く別のバージョン:arrows3dが含まれています。別の関数であるvectors3dは(原点からの)ベクトルの集合を描画し、それぞれにラベル付けを行います。

これらは幾何学的な3D図を描画するように調整されており、3D円錐で構成されたより美しい矢頭を持っています。

これらは、例えば、平均偏差空間に二変量重回帰モデルy ~ x1 + x2の3D表現を描く関数regvec3dで使用されます。ここ

は一例であり、vectors3d

library(rgl) 
library(matlib) 
vec <- rbind(diag(3), c(1,1,1)) 
rownames(vec) <- c("X", "Y", "Z", "J") 
open3d() 
vectors3d(vec, color=c(rep("black",3), "red"), lwd=2, radius=1/25) 
# draw the XZ plane, whose equation is Y=0 
planes3d(0, 0, 1, 0, col="gray", alpha=0.2) 
vectors3d(c(1,1,0), col="green", lwd=2, radius=1/25) 

enter image description here

関連する問題