如何并行向两个图添加点? (在R中)
我正在寻找并行向三个不同绘图添加点的方法。
我在一个窗口中有三个名为 s3d1
、s3d2
和 s3d3
的散点图
layout(matrix(c(1,2,1,3),2, 2, byrow = TRUE))
s3d1<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
s3d2<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
s3d3<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
如果我尝试向 s3d1
添加点>,
s3d1$points3d(mtcars[,3],mtcars[,4],mtcars[,5],col="red")
这些点将转到 s3d3
,但不会转到 s3d1
。我缺少什么?
更多信息:我在运行程序时获取数据点。因此,当我获得特定于该特定图的数据时,我需要向每个图添加点。
更新:
也尝试过 par()
函数
par(fig=c(0,0.65,0,1), new=TRUE)
s3d1<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
par(fig=c(0.7,1,0.5,1), new=TRUE)
s3d2<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
par(fig=c(0,0.65,0,1), new=TRUE)
s3d1$points3d(mtcars[,3],mtcars[,4],mtcars[,5],col="red")
s3d1$points3d
不会向 s3d1
添加新点(并且甚至连 s3d2
都没有)。有什么想法吗?
I am looking for ways to add points to three different plots in parallel.
I have three scatter plots named s3d1
, s3d2
and s3d3
in a single window
layout(matrix(c(1,2,1,3),2, 2, byrow = TRUE))
s3d1<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
s3d2<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
s3d3<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
If I try to add points to s3d1
,
s3d1$points3d(mtcars[,3],mtcars[,4],mtcars[,5],col="red")
The points would go to s3d3
but not s3d1
. What am I missing ?
More info : I obtain data points while running a program. So, I need to add points to each of these plots as-and-when I get the data specific to that particular plot.
Update :
Tried par()
function as well
par(fig=c(0,0.65,0,1), new=TRUE)
s3d1<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
par(fig=c(0.7,1,0.5,1), new=TRUE)
s3d2<-scatterplot3d(mtcars[,3],mtcars[,4],mtcars[,5],main="common",pch=20)
par(fig=c(0,0.65,0,1), new=TRUE)
s3d1$points3d(mtcars[,3],mtcars[,4],mtcars[,5],col="red")
s3d1$points3d
doesn't add new points to s3d1
(and not even to s3d2
). Any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您通过尝试执行 s3d1$points3d 来查看 points3d() 的源代码,您会发现它只是将点添加到假设为的现有绘图中已经开放了。换句话说,点/图不存储在 s3d1,2,3 对象中,而仅存储绘制到不同视图所需的转换信息。
Soo,要做你想做的事,你只需要使用普通的图形设备命令。例如,dev.new 将打开一个新的绘图窗口,而 dev.set 可以在活动窗口之间切换。您可以执行以下操作:
另请查看
?dev.new
以获取更多信息。If you look at the source of
points3d()
by just trying to executes3d1$points3d
, you'll see that it just adds points to an existing plot that is assumed to be already open. In other words, the points/plot are not stored in the s3d1,2,3 objects, but simply the transformation info needed to plot to the different views.Soo, to do what you're trying to do, you'll just have to use the normal graphics device commands. For instance,
dev.new
will open a new plot window, anddev.set
can switch between the active ones. You could do something like:Also check out
?dev.new
for more info.