格子图中的传说的外观和感觉

时间:2012-10-09 01:26:17

标签: r lattice

我正在寻找1)" A"," B"之间的更多垂直空间。和" C"," \ n"不是Iam lokking的解决方案。 2)我想改变符号和文本的绘图顺序。这意味着,首先我要绘制图例的线条以及该文本之后。

 attach(mtcars)
 gear.f<-factor(gear,levels=c(3,4,5),
 labels=c("3gears","4gears","5gears"))
 cyl.f <-factor(cyl,levels=c(4,6,8),
 labels=c("4cyl","6cyl","8cyl"))

 densityplot(~mpg|cyl.f,
      main="Density Plot by Number of Cylinders",
      xlab="Miles per Gallon"
     ,par.settings = list(superpose.line = list(col=c(1,2,3)))
     ,auto.key=list(corner = c(.98, .02),text = c("A", "B", "C")
                   ,lines=T,points=F)
            ) 

1 个答案:

答案 0 :(得分:3)

我认为从美学角度来看这是更好的,但你可以通过改变关键参数的'x'和'y'参数来调整它以适应你的感受:

 densityplot(~mpg|cyl.f,
      main="Density Plot by Number of Cylinders",
      xlab="Miles per Gallon"
     ,par.settings = list(superpose.line = list(col=c(1,2,3)))
     ,key = list(lines = list(col=c("black", "red", "green")),
                  text = list(c("A", "B", "C")), x=0.8, y=0.8, corner.x=0,corner.y=0 )
            )

我认为你不能用'auto.key'或'simpleKey'来做。)