Dear all, I have a plot with two lines and I'm using labcurbe (package Hmisc) to show the legend. Everything works well, except that the line displayed in legend box should have same style (plotting character) as the line in the plot. This is achieved by pch parameter and looks like that it's only supported via putKey function (according to the documention here: http://www.inside-r.org/packages/cran/Hmisc/docs/bezier). However, I've been unsucessful to correctly use this function (putKey). Could someone help me fix the code below? library(Hmisc) rm(list=ls(all=TRUE)) timeseries<-c(1950,2000,2050,2100) dataseries<-seq(1:4) dataseries1<-c(1,2,3,4) dataseries2<-c(1.5,2.5,3.5,4) plot(timeseries,dataseries,type="n") lines(timeseries,dataseries1,col="red",type="o",pch=19) lines(timeseries,dataseries2,col="blue",type="o",pch=5) curves<-list() curves[[1]]<-list(x=timeseries,y=dataseries1) curves[[2]]<-list(x=timeseries,y=dataseries2) dataSeriesLabels<-c("this legend should have pch=19","this legend should have pch=5") # PROBLEM BELOW #putKey(z=curves,labels=dataSeriesLabels,pch=19) labcurve(curves, dataSeriesLabels, type=rep("s",2), lty=rep("solid",2), lwd=1, col=c("red","blue"), keys="lines", cex=1, adj="auto", keyloc=c("auto"), transparent=FALSE) Thank you, -- Igor. igorjrr@gmail.com [[alternative HTML version deleted]]
Hello, In labcurve, use "keys=c(19,5)". It is said in examples provided in the help page. You should also modify the following lines:> lines(timeseries,dataseries1,col="red",type="l") > lines(timeseries,dataseries2,col="blue",type="l")Regards, Pascal 2013/8/23 Igor Ribeiro <igorjrr@gmail.com>> Dear all, > I have a plot with two lines and I'm using labcurbe (package Hmisc) to show > the legend. > Everything works well, except that the line displayed in legend box should > have same style (plotting character) as the line in the plot. This is > achieved by pch parameter and looks like that it's only supported via > putKey function (according to the documention here: > http://www.inside-r.org/packages/cran/Hmisc/docs/bezier). > > However, I've been unsucessful to correctly use this function (putKey). > Could someone help me fix the code below? > > library(Hmisc) > > rm(list=ls(all=TRUE)) > timeseries<-c(1950,2000,2050,2100) > dataseries<-seq(1:4) > dataseries1<-c(1,2,3,4) > dataseries2<-c(1.5,2.5,3.5,4) > plot(timeseries,dataseries,type="n") > lines(timeseries,dataseries1,col="red",type="o",pch=19) > lines(timeseries,dataseries2,col="blue",type="o",pch=5) > curves<-list() > curves[[1]]<-list(x=timeseries,y=dataseries1) > curves[[2]]<-list(x=timeseries,y=dataseries2) > dataSeriesLabels<-c("this legend should have pch=19","this legend should > have pch=5") > > # PROBLEM BELOW > #putKey(z=curves,labels=dataSeriesLabels,pch=19) > > labcurve(curves, dataSeriesLabels, type=rep("s",2), lty=rep("solid",2), > lwd=1, col=c("red","blue"), keys="lines", cex=1, adj="auto", > keyloc=c("auto"), transparent=FALSE) > > Thank you, > -- > Igor. > igorjrr@gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Hello, Please keep the r-list included when you reply. Why do you want to add points to lines only in the legend? If so, the legend would be incorrect. Regards, Pascal 2013/8/26 Igor Ribeiro <igorjrr@gmail.com>> Hi Pascal, > Thank you very much - your solution works partially - it will include the > pch in the legend, but also in the curve, which I don't want. I don't see a > way to remove the pch from the curve and leave it only in the legend. Do > you have any idea? method="none" doesn't work because then pch is not drawn > in the legend :( > Thanks! > Igor. > > > On Fri, Aug 23, 2013 at 3:09 AM, Pascal Oettli <kridox@ymail.com> wrote: > >> Hello, >> >> In labcurve, use "keys=c(19,5)". It is said in examples provided in the >> help page. >> >> Regards, >> Pascal >> >> >> 2013/8/23 Igor Ribeiro <igorjrr@gmail.com> >> >>> Dear all, >>> I have a plot with two lines and I'm using labcurbe (package Hmisc) to >>> show >>> the legend. >>> Everything works well, except that the line displayed in legend box >>> should >>> have same style (plotting character) as the line in the plot. This is >>> achieved by pch parameter and looks like that it's only supported via >>> putKey function (according to the documention here: >>> http://www.inside-r.org/packages/cran/Hmisc/docs/bezier). >>> >>> However, I've been unsucessful to correctly use this function (putKey). >>> Could someone help me fix the code below? >>> >>> library(Hmisc) >>> >>> rm(list=ls(all=TRUE)) >>> timeseries<-c(1950,2000,2050,2100) >>> dataseries<-seq(1:4) >>> dataseries1<-c(1,2,3,4) >>> dataseries2<-c(1.5,2.5,3.5,4) >>> plot(timeseries,dataseries,type="n") >>> lines(timeseries,dataseries1,col="red",type="o",pch=19) >>> lines(timeseries,dataseries2,col="blue",type="o",pch=5) >>> curves<-list() >>> curves[[1]]<-list(x=timeseries,y=dataseries1) >>> curves[[2]]<-list(x=timeseries,y=dataseries2) >>> dataSeriesLabels<-c("this legend should have pch=19","this legend should >>> have pch=5") >>> >>> # PROBLEM BELOW >>> #putKey(z=curves,labels=dataSeriesLabels,pch=19) >>> >>> labcurve(curves, dataSeriesLabels, type=rep("s",2), lty=rep("solid",2), >>> lwd=1, col=c("red","blue"), keys="lines", cex=1, adj="auto", >>> keyloc=c("auto"), transparent=FALSE) >>> >>> Thank you, >>> -- >>> Igor. >>> igorjrr@gmail.com >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@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. >>> >> >> > > > -- > Igor. > igorjrr@gmail.com > >[[alternative HTML version deleted]]