[Rd] bug in plot.ts?

Duncan Murdoch murdoch.duncan at gmail.com
Mon Dec 31 00:57:19 CET 2012


On 12-12-30 4:23 PM, Simone Giannerini wrote:
> Rui,
>
> thanks for looking into this and adding some relevant info,
> to me it looks more like a bug than lack of documentation, in any case
> we'll see if anyone of the core team would like to comment.

Here's a comment:  submit a patch.

Duncan Murdoch

>
> Ciao
>
> Simone
>
> On Sat, Dec 29, 2012 at 8:22 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
>> Just to add, on documentation, to my previous post. The following
>> illustrates my point.
>>
>> # This is the last instruction in the original post.
>> plot.ts(x=1, y=1, type="n", xy.labels=FALSE) # does not show the plot
>>
>> plot.ts(x=1, y=1, xy.labels=FALSE) # does show the plot, does not label it,
>> documented
>> plot.ts(x=1, y=1, type="n") # does show the plot (labels it), not properly
>> documented
>> plot.ts(x=1:151, y=1:151, type="n") # does not show the plot, documented
>>
>> Rui Barradas
>> Em 29-12-2012 19:07, Rui Barradas escreveu:
>>>
>>> Hello,
>>>
>>> You're right, it has to do with the argument xy.labels. The relevant
>>> lines in the source are
>>> (file src/library/stats/R/ts.R, function plot.ts)
>>>
>>>            [...]
>>>            n <- length(xy $ x)          #-> default for xy.l(ines|abels)
>>>            if(missing(xy.labels)) xy.labels <- (n <= 150)
>>>            if(!is.logical(xy.labels)) {
>>>                if(!is.character(xy.labels))
>>>                    stop("'xy.labels' must be logical or character")
>>>                do.lab <- TRUE
>>>            } else do.lab <- xy.labels
>>>            [...]
>>>            ptype <-
>>>            if(do.lab) "n" else if(missing(type)) "p" else type
>>>            plot.default(xy, type = ptype,
>>>            [...]
>>>            if(do.lab)
>>>                text(xy, labels =
>>>                 if(is.character(xy.labels)) xy.labels
>>>                 else if(all(tsp(x) == tsp(y))) formatC(time(x), width = 1)
>>>                 else seq_along(xy$x),
>>>                 col = col, cex = cex)
>>>            if(xy.lines)
>>>                lines(xy, col = col, lty = lty, lwd = lwd,
>>>                  type = if(do.lab) "c" else "l")
>>>            [...]
>>>
>>> Note that this is executed only if both 'x' and 'y' are passed to plot.ts.
>>> The variable 'do.lab' will control the plot.default type and whether the
>>> points are labeled using text() and the lines() type.
>>> This variable is set according to xy.labels. This behavior is more or
>>> less documented in plot.ts:
>>>
>>> |"xy.labels|||logical, indicating if |text
>>> <http://127.0.0.1:29428/library/stats/help/text>()| labels should be
>>> used for an x-y plot, /or/ character, supplying a vector of labels to be
>>>
>>> used. The default is to label for up to 150 points, and not for more."
>>>
>>> but I believe the documentation could be more clear. It could say that
>>> in the case of a y ~ x plot, to supress the plot xy.labels should be set
>>> to FALSE.
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>> Em 29-12-2012 17:04, Simone Giannerini escreveu:
>>>>
>>>> Dear all,
>>>>
>>>> I think I have found a buglet in plot.ts
>>>>
>>>> plot.ts(x=1,type="n")     # correct: does not show the plot
>>>> plot.ts(x=1,y=1,type="n") # not correct: does show the plot
>>>>
>>>> I did not investigate the problem in depth but it could be related to
>>>> the switch xy.labels, in fact
>>>>
>>>> plot.ts(x=1,y=1,type="n",xy.labels=TRUE) #  does show the plot
>>>> plot.ts(x=1,y=1,type="n",xy.labels=FALSE) # does not show the plot
>>>>
>>>>> sessionInfo()
>>>>
>>>> R version 2.15.2 Patched (2012-10-26 r61028)
>>>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>>>
>>>> locale:
>>>> [1] LC_COLLATE=Italian_Italy.1252  LC_CTYPE=Italian_Italy.1252
>>>> [3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
>>>> [5] LC_TIME=Italian_Italy.1252
>>>>
>>>> attached base packages:
>>>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>>
>>>> loaded via a namespace (and not attached):
>>>> [1] tools_2.15.2
>>>>
>>>>
>>>> Kind regards
>>>>
>>>> Simone
>>>> ______________________________________________________
>>>>
>>>>
>>>> Simone Giannerini
>>>> Dipartimento di Scienze Statistiche "Paolo Fortunati"
>>>> Universita' di Bologna
>>>> Via delle belle arti 41 - 40126  Bologna,  ITALY
>>>> Tel: +39 051 2098262  Fax: +39 051 232153
>>>> http://www2.stat.unibo.it/giannerini/
>>>>
>>>> ______________________________________________
>>>> R-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>>
>>>          [[alternative HTML version deleted]]
>>>
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>
>
>



More information about the R-devel mailing list