[R] Editable plot
Jim Lemon
drjimlemon at gmail.com
Fri May 1 04:20:53 CEST 2015
Hi Ishaq,
Well, you could do something absolutely ridiculous like this:
edit_my_plot<-function(x,y,z,w,r) {
npoints<-length(r)
index<-1
while(length(index)) {
matplot(x=matrix(r,nrow=3,ncol=4),y=cbind(x,y,z,w),
xlab="Number of iteration",ylab="Bias",
type="b",pch=c(1,22,22,22),lwd=2,
col=c("blue","red","green","forestgreen"))
title(main="Estimated Bias for the optimal response ",
col.main="red",font.main=4)
text(rep(1000,4),c(0.15,1.10,1.52,1.4),c("PM","VM","WMSE","LT"))
cat("Click on the point you want to move\n")
index<-identify(rep(r,4),c(x,y,z,w),n=1,plot=FALSE)
if(length(index)) {
cat("Now click where you want to move it\n")
newxy<-locator(n=1)
if(index < npoints + 1) {
x[index]<-newxy$y
r[index]<-newxy$x
}
else {
if(index < 2 * npoints + 1) {
y[index-npoints]<-newxy$y
r[index-npoints]<-newxy$x
}
else {
if(index < 3 * npoints + 1) {
z[index-2*npoints]<-newxy$y
r[index-2*npoints]<-newxy$x
}
else {
w[index-3*npoints]<-newxy$y
r[index-3*npoints]<-newxy$x
}
}
}
}
}
}
Jim
On Fri, May 1, 2015 at 5:25 AM, David L Carlson <dcarlson at tamu.edu> wrote:
> Do not post in html. You need to change your email software so that it sends messages in plain text only. Look below to see why.
>
> Your plot is edited by modifying the code you gave us to change the graph. Save the code in a script file, change it in any way you want and then run the code again to get a changed plot. You cannot edit the plot by selecting an element on the plot and changing its properties in some way.
>
> -------------------------------------
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of IZHAK shabsogh via R-help
> Sent: Thursday, April 30, 2015 2:04 AM
> To: R.
> Subject: [R] Editable plot
>
>
> Hello,Kindly assist me on how to make the plot from the following programm to be editable
>
> x<-c(0.84,1.03,0.96)y<-c(1.30,1.46,1.48)z<-c(1.32,1.47,1.5)w<-c(0.07,0.07,0.07)r<-c(500,1000,2000)
> # Graph cars using a y axis that ranges from 0 to 12plot(r,x, type="o", col="blue", ylim=c(0,1.5),lwd= 2, xlab = " Number of iteration",ylab=" Bias" )
> # Graph trucks with red dashed line and square pointslines(r,y, type="o", pch=22, lty=2, col="red",lwd=2)lines(r,z, type="o", pch=22, lty=3, col="green",lwd=2)lines(r,w, type="o", pch=22, lty=4, col="forestgreen",lwd=2)
> # Create a title with a red, bold/italic font#title(main="Estimated Bias for the optimal response ", col.main="red", font.main=4)
> #legend("center", lty = 1:4, col = 1:4, #legend = c("x","y", "z","w"))
> text(1000, 0.15, "PM")text(1000, 1.10, "VM")text(1000, 1.52, "WMSE")text(1000, 1.40, "LT")
>
> Thank youIshaq
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list