2

我一直在pairs()为此工作,并且花了很长时间试图添加图例或使用幻象符号来改变标题中物种的颜色以与点相关......任何见解将不胜感激!这是个问题。

# original code
pairs(iris[1:4], 
  main = "Width and Length (cm) of Iris's Petals and Sepals: Setosa, Veriscolor, Virginica", 
  pch = 24, bg = c("mediumorchid4", "mediumpurple1", "lightpink1")[unclass(iris$Species)], 
  upper.panel=NULL, labels=c("Sepal Length","Sepal Width","Petal Length","Petal Width"), 
  font.labels=1, cex.labels=2)
4

1 回答 1

5

这是一个更好的选择,以防(不是很好)接受的答案消失:

pairs(iris[1:4], 
  main = "Width and Length (cm) of Iris's Petals and Sepals: Setosa, Veriscolor, Virginica", 
  pch = 24, bg = c("mediumorchid4", "mediumpurple1", "lightpink1")[unclass(iris$Species)], 
  upper.panel=NULL, labels=c("Sepal Length","Sepal Width","Petal Length","Petal Width"), 
  font.labels=1, cex.labels=2)

legend(x = "topright",legend = levels(iris$Species),
        pch = 24,pt.bg = c("mediumorchid4", "mediumpurple1", "lightpink1"),
        inset = 0.1)

locator我没有像 Josh 建议的那样使用,而是盯着inset.

于 2013-10-14T21:44:08.373 回答