Add legend to a plot with R

♀尐吖头ヾ 提交于 2019-12-04 07:58:27
JJ Hilfiger
legend( "topleft", c("cars", "trucks", "cars1", "trucks1"), 
text.col=c("blue", "red", "yellow", "green") )

Use the ?legend command to see options, such other locations on the graph, besides "topleft" or text size, whether to have a box around the legend, etc.

For example

legend(
  "topright", 
  lty=c(1,2,1,2), 
  col=c("blue", "red", "yellow", "green"), 
  legend = c("cars", "trucks", "cars1", "trucks1")
)

See ?legend.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!