Hello, I am creating a plot/image using different data and a couple fit lines (see attached image). In the legend, I want the Default and Exponential symbol to be a line. I am using the pch command, I tried to use "-" to represent a line but does not work so I currently have set as a "1". Any thoughts or suggestions would be greatly appreciated. Below are the commands I used to create the legend: if(Prehour == 1) { leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", "High Z Outlier", "Default","Exponential (used)") } else { leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", "High Z Outlier", "Default (used)","Exponential") } legend("topleft", legend=leg.txt, col=c("black","yellow","red","orange","blue","black"), pch = c(16,16,16,16,1,1), cex=0.85 ) Thanks, Doug -- --------------------------------- Douglas M. Hultstrand, MS Senior Hydrometeorologist Metstat, Inc. Windsor, Colorado voice: 970.686.1253 email: dmhultst at metstat.com web: http://www.metstat.com --------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: ZR_lewis_pre_20100115_1400.png Type: image/png Size: 31386 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100204/d3abe4fb/attachment.png>
So your question is actually about mixing lines and symbols in the legend? What about: plot(1:10, 1:10) legend("topleft", legend=c("a", "b", "c"), lty=c(NA, -1, 1), pch=c(1, 2, NA)) Sarah> ----- Original Message ----- From: "Douglas M. Hultstrand" > <dmhultst at metstat.com> > To: "R mailing list" <r-help at r-project.org> > Sent: Thursday, February 04, 2010 4:59 PM > Subject: [R] Legend symbol? > > >> Hello, >> >> I am creating a plot/image using different data and a couple fit lines >> (see attached image). ?In the legend, I want the Default and Exponential >> symbol to be a line. ?I am using the pch command, I tried to use "-" to >> represent a line but does not work so I currently have set as a "1". >> Any thoughts or suggestions would be greatly appreciated. >> >> Below are the commands I used to create the legend: >> if(Prehour == 1) { >> ? ? ? leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", >> "High Z Outlier", "Default","Exponential (used)") >> ? ? ? } else { >> ? ? ? leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", >> "High Z Outlier", "Default (used)","Exponential") >> } >> legend("topleft", legend=leg.txt, >> col=c("black","yellow","red","orange","blue","black"), pch >> c(16,16,16,16,1,1), cex=0.85 ) >> >> Thanks, >> Doug >>-- Sarah Goslee http://www.functionaldiversity.org
Hi: not the best solution but, what about pch=45 or pch =47 ? Gabriela ----- Original Message ----- From: "Douglas M. Hultstrand" <dmhultst at metstat.com> To: "R mailing list" <r-help at r-project.org> Sent: Thursday, February 04, 2010 4:59 PM Subject: [R] Legend symbol?> Hello, > > I am creating a plot/image using different data and a couple fit lines > (see attached image). In the legend, I want the Default and Exponential > symbol to be a line. I am using the pch command, I tried to use "-" to > represent a line but does not work so I currently have set as a "1". > Any thoughts or suggestions would be greatly appreciated. > > Below are the commands I used to create the legend: > if(Prehour == 1) { > leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", > "High Z Outlier", "Default","Exponential (used)") > } else { > leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", > "High Z Outlier", "Default (used)","Exponential") > } > legend("topleft", legend=leg.txt, > col=c("black","yellow","red","orange","blue","black"), pch > c(16,16,16,16,1,1), cex=0.85 ) > > Thanks, > Doug > > -- > --------------------------------- > Douglas M. Hultstrand, MS > Senior Hydrometeorologist > Metstat, Inc. Windsor, Colorado > voice: 970.686.1253 > email: dmhultst at metstat.com > web: http://www.metstat.com > --------------------------------- > >--------------------------------------------------------------------------------> ______________________________________________ > R-help at r-project.org mailing list > 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. >___________________________________________________________________________ Aviso: ==== El contenido del presente e-mail y sus posibles adjuntos pertenecen al INTA y pueden contener informaci?n confidencial. Si usted no es el destinatario original de este mensaje y por este medio pudo acceder a dicha informaci?n, por favor solicitamos contactar al remitente y eliminar el mensaje de inmediato. Se encuentra prohibida la divulgaci?n, copia, distribuci?n o cualquier otro uso de la informaci?n contenida en el presente e-mail por parte de personas distintas al destinatario. This e-mail contents and its possible attachments belong to INTA and may contain confidential information. If this message was not originally addressed to you, but you have accessed to such information by this means, please contact the sender and eliminate this message immediately. Circulation, copy, distribution, or any other use of the information contained in this e-mail is not allowed on part of those different from the addressee. Antes de imprimir este mensaje, aseg?rese de que sea necesario. Proteger el medio ambiente est? tambi?n en su mano.
On Thu, Feb 4, 2010 at 14:59, Douglas M. Hultstrand <dmhultst at metstat.com> wrote:> Hello, > > I am creating a plot/image using different data and a couple fit lines (see > attached image). ?In the legend, I want the Default and Exponential symbol > to be a line. ?I am using the pch command, I tried to use "-" to represent a > line but does not work so I currently have set as a "1". ?Any thoughts or > suggestions would be greatly appreciated. > > Below are the commands I used to create the legend: > if(Prehour == 1) { > ? ? ? leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", "High Z > Outlier", "Default","Exponential (used)") > ? ? ? } else { > ? ? ? leg.txt <- c("Data", "Statistical Outlier", "Spatial Outlier", "High Z > Outlier", "Default (used)","Exponential") > } > legend("topleft", legend=leg.txt, > col=c("black","yellow","red","orange","blue","black"), pch > c(16,16,16,16,1,1), cex=0.85 ) > > Thanks, > Doug > > -- > --------------------------------- > Douglas M. Hultstrand, MS > Senior Hydrometeorologist > Metstat, Inc. Windsor, Colorado > voice: 970.686.1253 > email: dmhultst at metstat.com > web: http://www.metstat.com > --------------------------------- > > > ______________________________________________ > R-help at r-project.org mailing list > 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. > >You can combine pch and lty in the legend call. Try: legend("topleft", legend=leg.txt, col=c("black","yellow","red","orange","blue","black"), pch c(16,16,16,16,NA,NA),lty=c(rep(NA,4),1,1), cex=0.85 ) Also, try to stay away from the yellow color; it's very hard to make out against a white background.