我无法控制 R 中折线图中数据点的颜色。我有以下代码:
Pareto <- read.table("ParetoFront.csv",header=TRUE,sep=";")
dfP <- data.frame(Pareto$n,Pareto$z)
plot(dfP$Pareto_n,dfP$Pareto_z,xlim=c(1,max(dfP$Pareto.n)),
ylim=c(min(dfP$Pareto.z),max(dfP$Pareto.z)),xlab="n",ylab="z(n)",type="n")
lines(dfP$Pareto.n,dfPPareto.z,type="o",lwd=2,col="blue",pch=23,bg="red")
此代码生成一个带有蓝色线条和红色填充数据点的图表。我也想将数据点的边框颜色设为红色,但我不知道如何设置此 pch 参数。我试图在没有type="n"
参数的情况下绘制图表,以便我可以控制plot
函数(而不是lines
)中点的颜色但是当我运行以下代码时
Pareto <- read.table("ParetoFront.csv",header=TRUE,sep=";")
dfP <- data.frame(Pareto$n,Pareto$z)
plot(dfP$Pareto_n,dfP$Pareto_z,xlim=c(1,max(dfP$Pareto.n)),
ylim=c(min(dfP$Pareto.z),max(dfP$Pareto.z)),xlab="n",ylab="z(n)",
pch=23,col="red",bg="red")
我得到一个空图表:根本没有数据点。我不明白我的第二段代码有什么问题,我想知道是否有另一种方法来控制折线图中点的 bordel 颜色。
感谢您的帮助。