title: R plot legend Error in plot.xy(xy, type, ...) : invalid plot type
body: <p>When I want to add legend to a plot, it has Error in plot.xy(xy, type, ...) : invalid plot type, and the plot has no points showing up. Without legend and directly using pch, I'm able to get the points on the plot. Anything wrong in the code? Thanks.</p>
  
  <pre><code>plot(c(farm.metadata$coordinates["Longitude"],merraLoc$Global.Longitude,ruc.points$Global.Longitude),
  c(farm.metadata$coordinates["Latitude"],merraLoc$Global.Latitude,ruc.points$Global.Latitude),
  xlab="Latitude",ylab="Longitude", 
  legend("bottomright",c("Farm","Merra points","Ruc points-closest","Ruc points",pch=c(9,rep(19,4),20,rep(4,3)))),
  main=paste("MERRA, RUC, and FARM Coordinates For: ", farm.metadata$farm.name, sep=""))
  dev.off()
  </code></pre>