R legend placement in a plot

前端 未结 4 1636
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 18:03

I have a plot that has data that runs into the area I\'d like to use for a legend. Is there a way to have the plot automatically put in something like a header space above

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 18:15

    ?legend will tell you:

    Arguments

    x, y
    the x and y co-ordinates to be used to position the legend. They can be specified by keyword or in any way which is accepted by xy.coords: See ‘Details’.

    Details:

    Arguments x, y, legend are interpreted in a non-standard way to allow the coordinates to be specified via one or two arguments. If legend is missing and y is not numeric, it is assumed that the second argument is intended to be legend and that the first argument specifies the coordinates.

    The coordinates can be specified in any way which is accepted by xy.coords. If this gives the coordinates of one point, it is used as the top-left coordinate of the rectangle containing the legend. If it gives the coordinates of two points, these specify opposite corners of the rectangle (either pair of corners, in any order).

    The location may also be specified by setting x to a single keyword from the list bottomright, bottom, bottomleft, left, topleft, top, topright, right and center. This places the legend on the inside of the plot frame at the given location. Partial argument matching is used. The optional inset argument specifies how far the legend is inset from the plot margins. If a single value is given, it is used for both margins; if two values are given, the first is used for x- distance, the second for y-distance.

提交回复
热议问题