繁体   English   中英

在 R 中调整图例

[英]Adjust graph legend in R

你能帮我调整图表图例吗? 图形处于正确位置,但是我希望图例位于图形之外,即图像只需要进一步降低一点。

A <- data.frame(x=rnorm(100, 20, 2), y=rnorm(100, 20, 2))
B <- data.frame(x=rnorm(100, 21, 1), y=rnorm(100, 21, 1))

par(mar=c(5.1, 4.1, 4.1, 8.1), xpd=TRUE)

plot(y ~ x, A, ylim=range(c(A$y, B$y)), xlim=range(c(A$x, B$x)), pch=1,
     main="Scatter plot of two groups")
points(y ~ x, B, pch=3)

legend("bottomright",inset=c(-0,-0), legend= 3,title="The number is é:",title.col = "black", cex = 1.2)

在此处输入图片说明

例子: 在此处输入图片说明

legend(...) ,更改inset值会有所帮助。

A <- data.frame(x=rnorm(100, 20, 2), y=rnorm(100, 20, 2))
B <- data.frame(x=rnorm(100, 21, 1), y=rnorm(100, 21, 1))

par(mar=c(8.1, 4.1, 4.1, 4.1), xpd=TRUE)

plot(y ~ x, A, ylim=range(c(A$y, B$y)), xlim=range(c(A$x, B$x)), pch=1,
     main="Scatter plot of two groups")
points(y ~ x, B, pch=3)

legend("bottomright",inset=c(0,-0.375), legend= 3,title="The number is é:",title.col = "black", cex = 1.2)

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM