图例中的垂直空间 [英] Vertical spaces in legend

查看:108
本文介绍了图例中的垂直空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在格式化图例时遇到麻烦.我想增加图例每个元素之间的垂直空间.

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 you can help me if you want.

这是与图例相关的代码:

This is the code relative to the legend:

par(fig = c(0, 1, 0, 1), oma = c(0, 0, 0, 0), mar = c(0, 0, 0, 0), new = TRUE)
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"))

推荐答案

当您查阅legend手册时,例如通过在R控制台中键入?legend,您会发现

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

参数

...

x.intersp- 水平(x)间距的字符间距因子.

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

y.intersp- 垂直(y)线距离相同.

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

要修复您的图例,您可以将Interspacing因子设为2,这样您的legend通话就会变成

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.

这篇关于图例中的垂直空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆