如何在3D散点图中添加图例

时间:2018-10-22 03:37:59

标签: r 3d

我有一个3D散点图,看起来像这样

3D scatter plot

及其关联的代码如下

var str = "1  my data 001 12values";
var res = +str.match(/\d+(?=values)/i)[0];
console.log(res);

现在,我想在右下角添加图例以表明这些符号的含义

try {
          Desktop desktop = java.awt.Desktop.getDesktop();
          URI oURL = new URI("http://www.google.com");
          desktop.browse(oURL);
        } catch (Exception e) {
          e.printStackTrace();
        }

例如,三角形代表BPL,+代表RT,等等

1 个答案:

答案 0 :(得分:1)

您可以尝试以下方法:

library(scatterplot3d)
# define a plot
s3d <-scatterplot3d(data$nr, data$acc, data$ti, main = "3D Plot - Requirements, Accuracy & Time",
              xlab = "Number of requirements", ylab = "Accuracy", zlab = "Time", pch = data$label, angle = 45)

# add a legend
legend("topright",s3d$xyz.convert(18, 0, 12), pch = data$label, yjust=0,
       # here you define the labels in the legend
       legend = c('BPL','W','RT','S','WSM'), cex = 1.1
       )

enter image description here