I am trying to add a legend to the outside of a plot in R.
What I am using is:
png(height=400,width=842,"./rainfall.png")
par(family="serif",mar=c(4,6,4,1),oma=c(1,1,1,6),mfrow=c(1,2))
I create my plot, then:
par(xpd=TRUE)
legend(x="topright",inset=c(-0.2,0),c("4 year moving average","Simple linear trend"),lty=1,col=c("black","red"),cex=1.2)
legend("topleft",c("Annual total"),pch="*",col="blue",cex=1.2)
dev.off()
When i do this though the legend is cut off on the right, as shown in the image below. How can I get the legend to be visible outside the plot?
https://i.stack.imgur.com/q7CD4.jpg
Just to let you know, I have been trying the suggestions in this thread, ut they are not working for me: Plot a legend outside of the plotting area in base graphics?
Any help would be appreciated, Ciara