R plot 改变 Legend's Line 的 pch 颜色
R plot changing Legend's Line's pch color
我有我的图表,
plot(c(1:10),type = "l")
lines(c(1:10), type = "p", pch = 20,lwd = 4, col ="#4169E1" )
abline(h = 5,lwd = 2 , col = "#7f41e1")
abline(h = 0,lwd = 2, col = "#41e1b9")
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "black","#41e1b9"),cex=0.8,lwd=3, lty = c(1, 1, 1), pch = c(NA, 20, NA))
我想将图例中 b 的 pch 的颜色从黑色更改为图表“#4169E1”中看到的颜色。
非常感谢您的宝贵时间。
您可以通过先标注线然后标注点来实现,如下所示:
plot(c(1:10),type = "l")
lines(c(1:10), type = "p", pch = 20,lwd = 4, col ="#4169E1" )
abline(h = 5,lwd = 2 , col = "#7f41e1")
abline(h = 0,lwd = 2, col = "#41e1b9")
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "black","#41e1b9"),cex=0.8,lwd=3, lty = c(1, 1, 1), pch = c(NA, NA, NA))
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "#4169E1","#41e1b9"),cex=0.8,lwd=3,lty=c(0,0,0), pch = c(NA, 20, NA),bty="n")
我有我的图表,
plot(c(1:10),type = "l")
lines(c(1:10), type = "p", pch = 20,lwd = 4, col ="#4169E1" )
abline(h = 5,lwd = 2 , col = "#7f41e1")
abline(h = 0,lwd = 2, col = "#41e1b9")
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "black","#41e1b9"),cex=0.8,lwd=3, lty = c(1, 1, 1), pch = c(NA, 20, NA))
我想将图例中 b 的 pch 的颜色从黑色更改为图表“#4169E1”中看到的颜色。 非常感谢您的宝贵时间。
您可以通过先标注线然后标注点来实现,如下所示:
plot(c(1:10),type = "l")
lines(c(1:10), type = "p", pch = 20,lwd = 4, col ="#4169E1" )
abline(h = 5,lwd = 2 , col = "#7f41e1")
abline(h = 0,lwd = 2, col = "#41e1b9")
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "black","#41e1b9"),cex=0.8,lwd=3, lty = c(1, 1, 1), pch = c(NA, NA, NA))
legend("bottomright", legend=c("a", "b", "c"),
col=c("#7f41e1", "#4169E1","#41e1b9"),cex=0.8,lwd=3,lty=c(0,0,0), pch = c(NA, 20, NA),bty="n")