【问题标题】:plot level lines (2 circumferences) on a 3d plot在 3d 绘图上绘制水平线(2 个圆周)
【发布时间】:2013-10-26 08:17:04
【问题描述】:

我正在尝试将尺寸为 xy 的两个圆周与 3d 绘图一起绘制,并为两个圆的交点着色,我该怎么做?

# objective function
x <- seq(-1,1,.1)
y <- seq(-1,1,.1)
z <- x^2 + y^2

library(scatterplot3d)
library(plotrix)
scatterplot3d(x,y,z,pch=19,color="royalblue4")
draw.circle (1,1,1)
draw.circle (1,-1,1)

【问题讨论】:

  • 如果你想用scatterplot3d绘制两个draw.circles,我认为你不会成功,因为draw.circle“看到”2D(如果你打电话给axis(1) ,您将看到两个draw.circles 绘制的位置)。不过,我不确定您要达到的目标。您想在 3D 中绘制 2 个圆圈吗?对scatterplot3d(x, y.... 的调用与您要绘制的最后两个圆圈之间有什么联系?

标签: r 3d plot plotrix


【解决方案1】:

我不是很喜欢数学的东西,但我会发布作为答案,因为它可能有用,而且太大而无法发表评论。请原谅我的无知,如果我发表废话。

#your data
library(scatterplot3d)
x <- seq(-1,1,.1)
y <- seq(-1,1,.1)
z <- x^2 + y^2

ang = 60 #angle of the 3D plot. experiment with different values

#your 3D plot, with extended xx', yy' limits
sp3d <- scatterplot3d(x, y, z, pch=19, color="royalblue4", 
           xlim = c(-1, 3), ylim = c(-3, 3), angle = ang)

#to use parametric equations of circles
f <- seq(-2*pi, 2*pi, 0.1)

#circle1
sp3d$points(x = 1 + 1*cos(f), y = 1 + 1*sin(f), z = rep(0, length(f)), type = "l")
#circle2
sp3d$points(x = 1 + 1*cos(f), y = -1 + 1*sin(f), z = rep(0, length(f)), type = "l")

剧情是:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多