4

我在R.

plot(NA,xlim=c(0,1),ylim=c(0,1), xlab=expression(delta),ylab="K", xaxs="i",yaxs="i",main = "Zones of extreme equality and inequality in BO1") # Empty plot
cols <- c("red","black")
legend("topright",legend=c("Gini < 0.05","Gini > 0.6"), density=c(NA,NA), angle=c(NA,NA), col=cols)

图例中的框没有上色。这里有什么问题?

4

3 回答 3

12

尝试使用pch

legend("topright",
       legend=c("Gini < 0.05","Gini > 0.6"), 
       pch=15,
       col=cols)
于 2013-05-18T13:08:45.363 回答
5

您也可以只填充颜色:

legend("topright",legend=c("Gini < 0.05","Gini > 0.6"), fill=cols)
于 2015-08-01T22:17:12.510 回答
2

也许你可以这样尝试:

legend("topright",legend=c("Gini < 0.05","Gini > 0.6"), pch=15, col=cols)
于 2013-05-18T13:09:46.820 回答