Skip to content
Prev 110394 / 398500 Next

legend question

Hi Emili,

Even though you are calling your horizontal coordinate y, and vertical
coordinate z, the first and second arguments to legend(), namely x and y,
should be the horizontal and vertical coordinates, respectively; and they are
given in user coordinates (e.g., legend()'s x should be between 1960 and 1975
and legend()'s y should be between 1 and 4).

If you want to use normalized coordinates (i.e. 0 to 1), you can scale as in
this example:

legend(x = par("usr")[1] + diff(par("usr")[1:2])*normalizedCoordX,
       y = par("usr")[3] + diff(par("usr")[3:4])*normalizedCoordY,
       ...)

where normalizedCoordX and Y go from 0 to 1 (see ?par, par("usr") returns
vector of c(xmin,xmax,ymin,ymax) of user coordinates on a plot)

You can alternatively use legend(x = "topleft",...) or "bottomright", and so
on to place your legend.

If you want to add your legend outside of the plot, you should consider
increasing the margins using the 'mar' argument in par(), and also setting
par(xpd=TRUE) (so stuff can show up outside of the plotting region).

Best regards,
ST
within the data limits of your x and y)
--- Emili Tortosa-Ausina <Emili.Tortosa at eco.uji.es> wrote:

            
____________________________________________________________________________________
Food fight? Enjoy some healthy debate