[Rd] "plot.ts" doesn't respect the value of "pch" (+ blocked from Bugzilla signups)

Martin Maechler maechler at stat.math.ethz.ch
Fri Aug 26 10:52:51 CEST 2016


>>>>> Martin Maechler <maechler at stat.math.ethz.ch>
>>>>>     on Fri, 26 Aug 2016 09:31:41 +0200 writes:

>>>>> Gregory Werbin <greg.werbin at libertymail.net>
>>>>>     on Thu, 25 Aug 2016 15:21:05 -0400 writes:

    >> I've had a chance to read the source more thoroughly. The chain of 
    >> events is as follows:

    >> 1. Local function `plotts()` is defined with argument `cex` that 
    >> defaults to `par("cex")`
    >> 2. `...` is passed to `plotts()`. If "cex" is an element in `...`, 
    >> inside `plotts()` the variable `cex` is assigned thereby (overriding the 
    >> default arg). Importantly, this means that the element "cex" is captured 
    >> and _removed_ from `...`. `...` is eventually passed to `plot.window()`.
    >> 3.
    >> - In the univariate case (NCOL(x) == 1): When `lines.default()` is 
    >> called to actually plot the data 
    >> (https://github.com/wch/r-source/blob/trunk/src/library/stats/R/ts.R#L588 
    >> and 
    >> https://github.com/wch/r-source/blob/trunk/src/library/stats/R/ts.R#L597 
    >> for reference), `cex` is not included in the call.
    >> - In the bivariate case (NCOL(x) > 1): Because "cex" was captured and 
    >> removed from `...`, it is not passed to `plot.default` when it is called 
    >> (https://github.com/wch/r-source/blob/trunk/src/library/stats/R/ts.R#L548).

    >> It turns out that the "eating" is not being done by `...` but by the 
    >> signature of `plotts`.

    >> The documentation currently reads:

    >>> ...: additional graphical arguments, see 'plot', 'plot.default' and 
    >>> 'par'.

    >> This, to me, suggests parity with the 'plot' function in how the 
    >> arguments in '...' are handled. Therefore either the code is wrong or 
    >> the documentation is incomplete and misleading.

    > the code is not perfect aka "wrong" .. so the bug is there.
    > Making the minimal reproducible example more concise,

    > plot(as.ts((-10:12)^3), type="b", cex=.5)
    > plot(     ((-10:12)^3), type="b", cex=.5)

    > should plot identically ... but currently don't

And there are more (such) problems,
E.g, lty, and lwd are not propagated, in the (x,y) case,

 plot.ts(as.ts(1:300), cumsum(rnorm(300)), type = "b", cex = 0.5, lwd = 2)

and also not in the "multiple" / matrix case.

I will commit a fix to  R-devel in a moment... but would be glad
for a careful review.

Martin



More information about the R-devel mailing list