Vertical spaces in legend

后端 未结 1 1635
故里飘歌
故里飘歌 2021-02-05 17:41

I am having trouble formatting my legend. I would like to increase the vertical space between each element of the legend.

I post the image it produces and the code so yo

1条回答
  •  你的背包
    2021-02-05 18:13

    When you consult the legend manual, for example by typing ?legend into your R console, you find

    Arguments

    ...

    x.intersp - character interspacing factor for horizontal (x) spacing.

    y.intersp - the same for vertical (y) line distances.

    To fix your legend, you could start with an interspacing factor of 2, so your legend call would become

    legend("right", c(
        "$\\lambda < \\lambda_{cr}$ ",
        "$\\lambda < \\lambda_{cr}$",
        "$\\lambda = \\lambda_{cr}$ ",
        "$\\lambda = \\lambda_{cr}$ "
    ), xpd = TRUE, inset = c(0,0), bty = "n", lty = c(1, 1, 1, 1),
    lwd=2, col = c("black","green4","red","blue"),
    y.intersp=2)
    

    If that gives you too much or too little space between the items, adjust the value accordingly.

    0 讨论(0)
提交回复
热议问题