Re: [R] legend outside plot area

2010-08-15 Thread Pete B
Emily Maybe this will help # Data y1=rnorm(10) y2=runif(10) x=1:10 # Set XPD and Outer Margin par(xpd=NA,oma=c(3,0,0,0)) # Plot and Legend plot(x,y1,type="n",ylab="") lines(x,y1, col="red") lines(x,y2, col="blue") legend(par("usr")[1],par("usr")[3],c("Y1","Y2"),col=c("red","blue"),lty=1,xjust=

Re: [R] legend outside plot area

2010-08-15 Thread Hrishi Mittal
Emily, You need to set the xpd parameter to TRUE (using par) and use a negative value for the inset argument in the legend command. For example to place a legend on the right, legend("right",inset=c(-0.3,0),legend=somelegendvector) See ?legend and play around with the values of inset to get an

[R] legend outside plot area

2010-08-15 Thread Emily Forbes
Hi, please can you help me. When I add a legend to a boxplot it appears inside the plot area, how do you get it into the margins? I have already changed the parameters so there is space for it on the margin on the right hand side of the graph. Thanks, Emily