无法删除散点图中的图例

时间:2013-11-16 15:09:58

标签: r

这是我的代码

scatterplot(LitterMass~WormMass | Site,  reg.line=FALSE, smooth=FALSE, 
              spread=FALSE, id.method='mahal', id.n = 2, boxplots=FALSE, 
              span=0.5, by.groups=FALSE, data=wormdata,
              col=c("black","gray78","gray68","gray58","gray48"))

我正试图从它的默认位置移动图例,但是 图例( “topright”) 似乎没有工作,我还能尝试什么?

2 个答案:

答案 0 :(得分:3)

如果您不想在图表中添加图例,只需使用

即可
legend.plot = FALSE 

一般而言,开发人员将图例用于他们的图表作为第二步。大多数情况下,在窗口上绘制绘图后,只有您可以决定在哪里保留图表的图例以获得更好的可见性。

参考legend!页面了解更多详情及其使用示例。

答案 1 :(得分:0)

也许...

scatterplot(LitterMass~WormMass | Site,  reg.line=FALSE, smooth=FALSE, 
              spread=FALSE, id.method='mahal', id.n = 2, boxplots=FALSE, 
              span=0.5, by.groups=FALSE, data=wormdata,
              col=c("black","gray78","gray68","gray58","gray48"),
              legend.plot = FALSE)
# the important addition here is legend.plot = FALSE)


library(car)
scatterplot(prestige ~ income|type, data=Prestige, legend.coords="topleft")
# this plots with legend topleft
scatterplot(prestige ~ income|type, data=Prestige, legend.coords="topright")
# this plots with legend topright
scatterplot(prestige ~ income|type, data=Prestige, legend.plot=FALSE)
# this removes the legend