I have not been able to solve a problem trying to put a legend onto an image. After generating the image I try to add a legend with legend(locator(1),c("0","0.2","0.4","0.6","0.8","1"),horiz=T, fill=c("white",rev(heat.colors(5)))) If I place the legend on top of the image the text and fill boxes are shown, but unfortunately over the top of the image. If I try to locate the legend somewhere else, in the top margin for instance, the text (the legend) is displayed but not the fill boxes. If I include the par option xpd, say par(xpd=NA) nothing changes. I thought this would stop this would allow the legend to be printed inside the device but it doesn't seem to matter what xpd value I use, the fill boxes do not appear anywhere except over the image. There must be another option that controls this. Can anyone help? Regards Ross Darnell -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Ross Darnell wrote:> I have not been able to solve a problem trying to put a legend onto animage.... If I read your question correctly, you could have one or more of the following problems 1) Your plot doesn't have enough blank space to fit the legend. Use xlim= and ylim= to expand the plot enough to fit the legend inside, then eyeball the legend into place by passing x and y values to legend() in user units instead of using locator=. 2) You don't want the legend in the plot and don't have enough space outside the plot for it. Use par() to set a wider margin, xpd() to _allow_ you to put the legend outside and pass x and y values to legend(). 3) You want a really compact legend You _can_ fool around with the legend() function, but it's probably easier to simply squeeze in filled rectangles and use text() to jam in a legend. You will have to fiddle with the positioning to get it to look good. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._