R lines type in a glm/predict model

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

R lines type in a glm/predict model

laurafdez56
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))

Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

Sarah Goslee
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
<[hidden email]> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

Michael Dewey-3
In reply to this post by laurafdez56
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.
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

laurafdez56
Dear Michael!
Here is my database: 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
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

laurafdez56
In reply to this post by Sarah Goslee
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
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

David Winsemius
In reply to this post by laurafdez56

On Sep 14, 2015, at 1:18 PM, laurafdez56 wrote:

> 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.

If you do not want point symbols, then you have not explained yourself well. Can you offer a link to an example in your domain of investigation for "putting squares" to signify value that would otherwise be represented with a line? Are you hoping to represent a value by varying the dimensions of a square with relative proportions of the sides or areas? (This is not generally considered an unambiguous strategy because of the manner in which humans perceive areas.)


--
David.

>
> 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.
>
> ______________________________________________
> [hidden email] 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.

David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

laurafdez56
Hey David!
This is my graphic. sup.png
I want only to change the line type (square line instead dotted line) in order to distinguish the species.

Thank you very much!
Laura
 
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

Rolf Turner
On 15/09/15 20:21, laurafdez56 wrote:
> Hey David!
> This is my graphic.  sup.png
> <http://r.789695.n4.nabble.com/file/n4712271/sup.png>
> I want only to change the line type (square line instead dotted line) in
> order to distinguish the species.

What *on earth* do you mean by a "square line"?

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

John Kane
Hi Rolf,

I think Laura wants something like this for one of the curves, although I'm guessing.

aa  <-  1:100
plot(aa, pch = 22)

John Kane
Kingston ON Canada


> -----Original Message-----
> From: [hidden email]
> Sent: Tue, 15 Sep 2015 22:45:21 +1200
> To: [hidden email], [hidden email]
> Subject: Re: [R] R lines type in a glm/predict model
>
> On 15/09/15 20:21, laurafdez56 wrote:
>> Hey David!
>> This is my graphic.  sup.png
>> <http://r.789695.n4.nabble.com/file/n4712271/sup.png>
>> I want only to change the line type (square line instead dotted line) in
>> order to distinguish the species.
>
> What *on earth* do you mean by a "square line"?
>
> cheers,
>
> Rolf Turner
>
> --
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
>
> ______________________________________________
> [hidden email] 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.

____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

Michael Dewey-3
In reply to this post by laurafdez56
Dear Laura

As you can see you have us all very puzzled. I think something is
getting lost in translation between the language of Cervantes and the
language of Shakespeare.

Perhaps
1 - send a picture of a square line
2 - tell us what square line is in Spanish
3 - find the Spanish language R help list and try there

Obviously do not try all three at once

On 15/09/2015 09:21, laurafdez56 wrote:

> Hey David!
> This is my graphic.  sup.png
> <http://r.789695.n4.nabble.com/file/n4712271/sup.png>
> I want only to change the line type (square line instead dotted line) in
> order to distinguish the species.
>
> Thank you very much!
> Laura
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712271.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

laurafdez56
In reply to this post by Rolf Turner
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

Thank you very much for your help!
Un abrazo muy fuerte para todos!!

Laura
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

laurafdez56
In reply to this post by Michael Dewey-3

Dear Michael!!

Thank you very much for your help!!

Finally I did it, as you can see: 



I didn`t explain myself properly, sorry!!!

Thank you very much for your help!! 


Un abrazo fuerte!!


Laura Fernández Pérez
Doctorado en Ecología, Conservación y Restauración de Ecosistemas
Departamento de Ciencias de la Vida 
Universidad de Alcalá
Alcalá de Henares, Madrid, España.




De: Michael Dewey-3 [via R] <ml-node+[hidden email]>
Enviado: martes, 15 de septiembre de 2015 19:20
Para: Fernández Pérez Laura
Asunto: Re: R lines type in a glm/predict model
 
Dear Laura

As you can see you have us all very puzzled. I think something is
getting lost in translation between the language of Cervantes and the
language of Shakespeare.

Perhaps
1 - send a picture of a square line
2 - tell us what square line is in Spanish
3 - find the Spanish language R help list and try there

Obviously do not try all three at once

On 15/09/2015 09:21, laurafdez56 wrote:

> Hey David!
> This is my graphic.  sup.png
> <http://r.789695.n4.nabble.com/file/n4712271/sup.png>
> I want only to change the line type (square line instead dotted line) in
> order to distinguish the species.
>
> Thank you very much!
> Laura
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712271.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.



If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/R-lines-type-in-a-glm-predict-model-tp4712219p4712285.html
To unsubscribe from R lines type in a glm/predict model, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: R lines type in a glm/predict model

John Kane
In reply to this post by laurafdez56
I thought that was was what you wanted. Congratulations.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: [hidden email]
> Sent: Tue, 15 Sep 2015 13:40:21 -0700 (PDT)
> To: [hidden email]
> 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.
>
> ______________________________________________
> [hidden email] 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!

______________________________________________
[hidden email] 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.