在由 rgl 包 plot3d 构建的球体上有名称 [英] Have names on the spheres built by rgl package plot3d

查看:57
本文介绍了在由 rgl 包 plot3d 构建的球体上有名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 R 中使用 plot3d(rgl) 构建 3d 图形时,有没有办法显示名称,因为当我在同一坐标上绘制多个球体时,很难定位球体属于哪个条目.例如,我有数据:

Is there a way to have the names shown when use plot3d(rgl) in R to build a 3d graph, cause it's hard to locate which entry the sphere belongs to when I have many spheres to plot on the same coordinate. For example, I have the data:

    x   y   z
A   0.1 -0.5    3.2
B   -1.1    1.2 0.8
C   2.0 2.1 0.6
......

plot3d(data,type="s",radius=0.025)

但是,我想在图表上显示名称 A、B、C,因为这样更容易观察.或者仅当我将鼠标放在一个特定的球体上时才显示名称.我尝试使用不同的颜色,但是当我有 20 个球体时,它似乎会用完颜色或颜色太接近而无法区分.

But, I want to have the name A, B, C shown on the graph as it's easier to observe. Or to have the name shown only when I put the mouse onto one specific sphere. I have tried to use different colors, but when I have like 20 spheres, it seems it will run out of colors or colors are too close to distinguish.

推荐答案

在库 rgl 中有一个函数 text3d() 可用于在 plot 内绘制文本.此示例说明如何将行名称绘制为文本.

There is a function text3d() in library rgl that can be used to plot texts inside plot. This example shows how to plot row names as texts.

plot3d(data,type="s",radius=0.025)
text3d(data$x,data$y,data$z,text=rownames(data))

这篇关于在由 rgl 包 plot3d 构建的球体上有名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆