【问题标题】:how to plot dotted / dashed lines using rgl如何使用 rgl 绘制虚线/虚线
【发布时间】:2014-07-20 03:31:38
【问题描述】:

我正在尝试使用 rgl 绘制一些 3d 形状,但我想使用虚线/点线连接我的点。我怎样才能做到这一点?目前我有

require(rgl)

p1 <- c(0,0,0)
p2 <- c(1,0,0)
p3 <- c(1,1,0)
p4 <- c(0,1,0)
p5 <- c(0.5,0.5,0.5)

mat <- cbind(p1,p2,p3,p4,p1,p5,p2,p5,p3,p5,p4)
x <- as.numeric(mat[1,])
y <- as.numeric(mat[2,])
z <- as.numeric(mat[3,])

plot3d(x,y,z,type="l",lwd=2,lty=3,box=FALSE,axes=FALSE,xlab="",ylab="",zlab="")

所以lwd 有效,但lty 无效。我也试过lty="dashed",但无济于事。

我基本上想绘制我可以绘制的 3d 形状

  1. 轻松旋转/缩放(就像 rgl 提供的一样)
  2. 导出为矢量图形格式(如 rgl.postscript)
  3. 指定线型和颜色

如果有其他包可以实现,也请分享。谢谢。

【问题讨论】:

    标签: r rgl


    【解决方案1】:

    我认为你可以用 rgl 包做的最好的是将顶点作为点:

    vertices <- c(t(cbind(x,y,z,1)))
    indices <- seq_along(x)
    dot3d( qmesh3d(vertices,indices) )
    

    【讨论】:

    • 嗨,当我使用 x,y,z 参数运行上面的代码时,我收到一条警告消息:Warning message: In matrix(indices, nrow = 4) : data length [11] is not a sub-multiple or multiple of the number of rows [4],5 个点被绘制为 5 个点。这些点根本没有连接。这是预期的输出吗?
    • 以上五我以下:数据长度[11]不是行数[4]的约数或倍数且没有数字!
    猜你喜欢
    • 2022-11-08
    • 2015-02-22
    • 2010-10-07
    • 2012-09-23
    • 1970-01-01
    • 2020-10-24
    • 2014-11-19
    • 1970-01-01
    • 2021-01-24
    相关资源
    最近更新 更多