[英]Adjust graph done in R
I would like help with my graph.我想帮助我的图表。 I generated a graph, but I would like to insert IdealPoint and SolutionFinal together with the graph.
我生成了一个图表,但我想将 IdealPoint 和 SolutionFinal 与图表一起插入。 I didn't insert all the code, because it's really big.
我没有插入所有代码,因为它真的很大。 Unfortunately, I was unable to make executable code, but I believe I don't have to for this case.
不幸的是,我无法制作可执行代码,但我相信我不必为这种情况。 I would just like someone to help me insert these two (IdealPoint and SolutionFinal) in the graph.
我只想有人帮我在图中插入这两个(IdealPoint 和 SolutionFinal)。
Could you help me solve it??能帮我解决吗??
Thank you very much!非常感谢!
Best Regards.此致。
.
if(Filter2==1 & s[1]>0){
Mean<-subset(mean, mean[,1] <=s[1])
} else{Mean<-mean}
Mean<-Mean[,2:3]
IdealPoint<-as.matrix(t(c(min(Mean[,1]),max(Mean[,2]))))
aux_solution<-as.matrix(dist(rbind(Mean,IdealPoint)))
IdealPoint
distancia_solution<-min(aux_solution[as.matrix(dim(Mean))[1,1]+1,1:as.matrix(dim(Mean))[1,1]])
a<-which(aux_solution[dim(Mean)[1]+1,]==distancia_solution)
SolutionFinal<-Mean[a[1],]
SolutionFinal
plot(Mean[,1],Mean[,2],xlab="Range of Coverage", ylab="Minimal waste")
You don't provide a reproducible example ( https://stackoverflow.com/help/minimal-reproducible-example ) so I can't check this ahead of time, but you should be able to just use the function points()
to add other points.您没有提供可重现的示例( https://stackoverflow.com/help/minimal-reproducible-example )所以我无法提前检查,但您应该能够使用 function
points()
来添加其他点。
So something like所以像
plot(Mean[,1],Mean[,2],xlab="Range of Coverage", ylab="Minimal waste")
points(IdealPoint[,1],IdealPoint[,2])
points(SolutionFinal[,1],SolutionFinal[,2])
EDIT编辑
If you change the last line to如果将最后一行更改为
points(SolutionFinal[1],SolutionFinal[2])
Then it does work.然后它确实有效。 But the problem is that it is stacking all the points.
但问题是它正在堆叠所有点。 So
SolutionFinal[1],SolutionFinal[2]
is the same as IdealPoint[,1],IdealPoint[,2]
and the top-left point in your plot.所以
SolutionFinal[1],SolutionFinal[2]
与IdealPoint[,1],IdealPoint[,2]
和 plot 中的左上角相同。
You can see them if you jitter the points a bit with jitter
如果您用
jitter
稍微抖动点,您可以看到它们
plot(jitter(Mean[,1],1.5),Mean[,2],xlab="Range of Coverage", ylab="Minimal waste")
points(jitter(IdealPoint[,1],1.5),IdealPoint[,2],col="red")
points(jitter(SolutionFinal[1],1.5),jitter(SolutionFinal[2],1.5),col="purple")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.