Hi everyone! I want to change the line type into a square/circle/triangle in a plot, and I can not find the way, could someone help me please?? I used the glm/predict function to predict the curves. Here is my code: glm1<-glm(Supervivencia~Temperatura*Especie,pinos,family=binomial) range(pinos$Temperatura) xv<-5:-30 sp1<-rep("P.halepensis:-11.6(-10.6,-12)",length(xv)) sp2<-rep("P.nigra:-23.6(-22.9,-23.9)",length(xv)) sp3<-rep("P.pinaster:-19.2(-18.7,-19.4)",length(xv)) sp4<-rep("P.pinea:-12.4(-11.8,-12.7)",length(xv)) sp5<-rep("P.sylvestris:-21.4(-20.9,-21.6)",length(xv)) sp6<-rep("P.uncinata:-21.3(-20.7,-21.6)",length(xv)) yv1<-predict(glm1,list(Temperatura=xv,Especie=sp1),type="response") yv2<-predict(glm1,list(Temperatura=xv,Especie=sp2),type="response") yv3<-predict(glm1,list(Temperatura=xv,Especie=sp3),type="response") yv4<-predict(glm1,list(Temperatura=xv,Especie=sp4),type="response") yv5<-predict(glm1,list(Temperatura=xv,Especie=sp5),type="response") yv6<-predict(glm1,list(Temperatura=xv,Especie=sp6),type="response") plot(Supervivencia~Temperatura,pinos, xlab=(expression(Temperature * degree~C)), ylab="Survival",type="n") lines(xv,yv1,lwd=2,lty=5, col="black")###halepensis lines(xv,yv2,lwd=2,lty=6, col="black")###nigra lines(xv,yv3,lwd=2,lty=1, col="black")###pinaster lines(xv,yv4,lwd=2,lty=4, col="black")###pinea lines(xv,yv5,lwd=2,lty=3, col="black")###sylvestris lines(xv,yv6,lwd=2,lty=2, col="black")###uncinta abline(0.5,0, col="black", lty=7) legend(legend=levels(pinos$Especie),"topleft",bty="n",lty=c(lty=5,lty=6,lty=1,lty=4,lty=3,lty=2)) -- View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219.html Sent from the R help mailing list archive at Nabble.com.
It's not clear to me quite what you want, but you might look at the type="b" argument to lines, or potentially ?points Sarah On Mon, Sep 14, 2015 at 8:11 AM, laurafdez56 <laura.fernandezp at edu.uah.es> wrote:> Hi everyone! > I want to change the line type into a square/circle/triangle in a plot, and > I can not find the way, could someone help me please?? I used the > glm/predict function to predict the curves. > > Here is my code: > > glm1<-glm(Supervivencia~Temperatura*Especie,pinos,family=binomial) > > range(pinos$Temperatura) > xv<-5:-30 > sp1<-rep("P.halepensis:-11.6(-10.6,-12)",length(xv)) > sp2<-rep("P.nigra:-23.6(-22.9,-23.9)",length(xv)) > sp3<-rep("P.pinaster:-19.2(-18.7,-19.4)",length(xv)) > sp4<-rep("P.pinea:-12.4(-11.8,-12.7)",length(xv)) > sp5<-rep("P.sylvestris:-21.4(-20.9,-21.6)",length(xv)) > sp6<-rep("P.uncinata:-21.3(-20.7,-21.6)",length(xv)) > > yv1<-predict(glm1,list(Temperatura=xv,Especie=sp1),type="response") > yv2<-predict(glm1,list(Temperatura=xv,Especie=sp2),type="response") > yv3<-predict(glm1,list(Temperatura=xv,Especie=sp3),type="response") > yv4<-predict(glm1,list(Temperatura=xv,Especie=sp4),type="response") > yv5<-predict(glm1,list(Temperatura=xv,Especie=sp5),type="response") > yv6<-predict(glm1,list(Temperatura=xv,Especie=sp6),type="response") > > > plot(Supervivencia~Temperatura,pinos, xlab=(expression(Temperature * > degree~C)), ylab="Survival",type="n") > lines(xv,yv1,lwd=2,lty=5, col="black")###halepensis > lines(xv,yv2,lwd=2,lty=6, col="black")###nigra > lines(xv,yv3,lwd=2,lty=1, col="black")###pinaster > lines(xv,yv4,lwd=2,lty=4, col="black")###pinea > lines(xv,yv5,lwd=2,lty=3, col="black")###sylvestris > lines(xv,yv6,lwd=2,lty=2, col="black")###uncinta > abline(0.5,0, col="black", lty=7) > legend(legend=levels(pinos$Especie),"topleft",bty="n",lty=c(lty=5,lty=6,lty=1,lty=4,lty=3,lty=2)) > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219.html > Sent from the R help mailing list archive at Nabble.com. >-- Sarah Goslee http://www.functionaldiversity.org
Dear Laura The line type is usually something like: solid, dotted, dashed, ... The shapes you suggest are usually point symbols. When you repost perhaps it would be a good idea to 1 - give us a small dataset 2 - just supply code for two species 3 - tell us what you see, and what you really wanted to see On 14/09/2015 13:11, laurafdez56 wrote:> Hi everyone! > I want to change the line type into a square/circle/triangle in a plot, and > I can not find the way, could someone help me please?? I used the > glm/predict function to predict the curves. > > Here is my code: > > glm1<-glm(Supervivencia~Temperatura*Especie,pinos,family=binomial) > > range(pinos$Temperatura) > xv<-5:-30 > sp1<-rep("P.halepensis:-11.6(-10.6,-12)",length(xv)) > sp2<-rep("P.nigra:-23.6(-22.9,-23.9)",length(xv)) > sp3<-rep("P.pinaster:-19.2(-18.7,-19.4)",length(xv)) > sp4<-rep("P.pinea:-12.4(-11.8,-12.7)",length(xv)) > sp5<-rep("P.sylvestris:-21.4(-20.9,-21.6)",length(xv)) > sp6<-rep("P.uncinata:-21.3(-20.7,-21.6)",length(xv)) > > yv1<-predict(glm1,list(Temperatura=xv,Especie=sp1),type="response") > yv2<-predict(glm1,list(Temperatura=xv,Especie=sp2),type="response") > yv3<-predict(glm1,list(Temperatura=xv,Especie=sp3),type="response") > yv4<-predict(glm1,list(Temperatura=xv,Especie=sp4),type="response") > yv5<-predict(glm1,list(Temperatura=xv,Especie=sp5),type="response") > yv6<-predict(glm1,list(Temperatura=xv,Especie=sp6),type="response") > > > plot(Supervivencia~Temperatura,pinos, xlab=(expression(Temperature * > degree~C)), ylab="Survival",type="n") > lines(xv,yv1,lwd=2,lty=5, col="black")###halepensis > lines(xv,yv2,lwd=2,lty=6, col="black")###nigra > lines(xv,yv3,lwd=2,lty=1, col="black")###pinaster > lines(xv,yv4,lwd=2,lty=4, col="black")###pinea > lines(xv,yv5,lwd=2,lty=3, col="black")###sylvestris > lines(xv,yv6,lwd=2,lty=2, col="black")###uncinta > abline(0.5,0, col="black", lty=7) > legend(legend=levels(pinos$Especie),"topleft",bty="n",lty=c(lty=5,lty=6,lty=1,lty=4,lty=3,lty=2)) > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Michael http://www.dewey.myzen.co.uk/home.html
Dear Michael! Here is my database: Survival_help.csv <http://r.789695.n4.nabble.com/file/n4712255/Survival_help.csv> That is just what I thought about the point symbols, but is there possible to put square, circle or whatever instead lines solid, dotted, etc?? I draw the graphics with dotted lines, but I want to put squares. Thank you very much for you help!!! Laura -- View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712255.html Sent from the R help mailing list archive at Nabble.com.
Dear Sara!! Thank you for your advice, but is very weird the graphic type="b. I only want to draw square line instead dotted line, do I explain myself? Thank you!! Laura -- View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712256.html Sent from the R help mailing list archive at Nabble.com.
I thought that was was what you wanted. Congratulations. John Kane Kingston ON Canada> -----Original Message----- > From: laura.fernandezp at edu.uah.es > Sent: Tue, 15 Sep 2015 13:40:21 -0700 (PDT) > To: r-help at r-project.org > Subject: Re: [R] R lines type in a glm/predict model > > Jajaja! > Well, may be I didn't express myself properly, but I did it!!!! See my > new-beautiful graphic and I really want to say square-line :). Finally, > it > was very easy, but I had to think in a big group with you guys! > I speak/read/write english very well, but perhaps my thoughts were not > very > clear, you don't need to be mean to me Rolf and Michael! ;) > sup.sup <http://r.789695.n4.nabble.com/file/n4712296/sup.sup> > > Thank you very much for your help! > Un abrazo muy fuerte para todos!! > > Laura > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712296.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!