Hi Pascal,
Still... there is something wrong. I changed the two lines as you
suggested, and now I'm using the keys parameter. But the output is not as
expected. That's why I was controlling the points using points function,
because that works well.
Let me try to show you with the code:
# Example 1 - the points are not over the lines and are not distributed the
way I want (see Example 2)
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="l")
lines(timeseries,dataseries2,col="blue",type="l")
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")
labcurve(curves, dataSeriesLabels, type=rep("s",2), lty=rep("solid",2),
lwd=1, col=c("red","blue"), keys=c(19,5), cex=1, adj="auto",
keyloc=c("auto"), transparent=FALSE)
# Example 2 - this is the way I want the lines, but then I can't put the
points (pch) in the legend...
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")
points (timeseries, dataseries1, pch=19, col="red", cex=1.3)
lines(timeseries,dataseries1,col="red",type="l")
points (timeseries, dataseries2, pch=5, col="blue", cex=1.3)
lines(timeseries,dataseries2,col="blue",type="l")
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")
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)
You see the difference? I need to put the legend generated in Example 1 in
the plot generated in Example 2. So far I was unable to mix them!
I appreciate all your help, thank you.
Igor.
On Mon, Aug 26, 2013 at 9:44 PM, Pascal Oettli <[email protected]> wrote:
> Hello,
>
> That is why I changed 2 lines in the code. Because points are misplaced if
> you keep points with the lines.
>
> Regards,
> Pascal
>
>
> 2013/8/27 Igor Ribeiro <[email protected]>
>
>> Because I'm already controlling points using points function. So I don't
>> want labcurve to change anything on the lines... Just draw the legend the
>> way I need.
>> On Aug 26, 2013 8:35 PM, "Pascal Oettli" <[email protected]> wrote:
>>
>>> 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 <[email protected]>
>>>
>>>> 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 <[email protected]>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 <[email protected]>
>>>>>
>>>>>> 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.
>>>>>> [email protected]
>>>>>>
>>>>>> [[alternative HTML version deleted]]
>>>>>>
>>>>>> ______________________________________________
>>>>>> [email protected] 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.
>>>> [email protected]
>>>>
>>>>
>>>
>
--
Igor.
[email protected]
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.