gpt4 book ai didi

r - 在 R 中绘制图外的图例

转载 作者:行者123 更新时间:2023-12-01 09:18:10 30 4
gpt4 key购买 nike

我正在尝试使用 xpd=TRUE 将图例放在情节之外但传说一直在情节中绘制。我怎样才能解决这个问题?

x = c(0,0,1,1,1)
y = c(0.4991,1.1423,1.2258,1.158,0.5148)
dat<-cbind(x,y)
point_shape = c(10,15,10,15,1)
dat<-data.frame(x,y,point_shape)

myTicks<-c(0,1)
plot(dat[,1],dat[,2], yaxt="n", xaxt="n", xlab="", ylab="",pch = dat$point_shape)
abline(0.4991,0.7267)
abline(1.1423,0.0157)
abline(0.4991,0.0157,lty=2)
axis(side = 1, at = myTicks)
axis(side = 2, at = myTicks)


legend("bottomleft", legend = c("apple", "orange", "tree"),
bty = "n", xpd=FALSE, mar(c(7,7,7,7)), cex = 1, pch = c(10, 15, 1))

最佳答案

使用 inset 并使 xpd 为 true

legend("bottomleft", legend = c("apple", "orange", "tree"), inset=c(-0.15,0),
bty = "n", xpd=TRUE, mar(c(7,7,7,7)), cex = 1, pch = c(10, 15, 1))

关于r - 在 R 中绘制图外的图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50737256/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com