gpt4 book ai didi

r - R pch 中的图例未填充

转载 作者:行者123 更新时间:2023-12-05 03:12:57 25 4
gpt4 key购买 nike

尝试使用 pch 绘制图例,我的理解是这些应该被填充,但看起来并非如此。这是 Windows 图形的问题吗?

legend(36, 79,
legend = c(expression("a"["a"]), expression("b"["b"]), expression("c"["c"])),
pch = c(21, 8, 24), col = c(grey(0.1), grey(0.3), grey(0.5)),
cex = 1.3, bty = "n"
)

enter image description here通常不会发布,但这是要提交的论文,图中的图例和图形应该匹配谢谢!

最佳答案

我们需要填写pt.bg参数:

看下面的例子:

#dummy data
set.seed(123)
df <- data.frame(x=runif(10),y=runif(10),
colour=rep(c("blue","green"),5),
background=rep(c("grey30", "grey70"),5),
shape=rep(c(21,24),5),stringsAsFactors = FALSE)

#plot
plot(df$x,df$y,col=df$colour,bg=df$background,pch=df$shape,cex=2)
points(x=0.5,y=0.5,pch=8,col="red",cex=2)

#add legend, pt.bg is need to fill in the background of the shape
legend(0.01,0.5,
legend = c(expression("LBM"["MR-AC"]),
expression("LBM"["Formula"]),
expression("LBM"["MR-AC corrected"])),
pch = c(21,24,8),
col = c("blue","green","red"),
pt.bg = c("grey30","grey70"),
cex=2)

enter image description here

关于r - R pch 中的图例未填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31914852/

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