绘制 xts 对象 - 传递 lwd 和 col 参数的值会产生错误 [英] plotting xts objects - passsing values for lwd and col parameters creating errors
问题描述
每当我尝试使用为参数 col 和 lwd 传递的值绘制我的 xts 对象时,它都会返回一个错误,指出参数 col(如果我注释掉 col,则为 lwd)匹配多个值.这是函数的样子 -
Whenever I try to plot my xts object with values passed for parameter col and lwd, it returns an error saying that the parameter col (and then lwd if I comment out col) matched multiple values. Here is what the function looks like -
数据是一个 xts 对象
data is an xts object
plot(data, lwd=2, col="red")
安装 xtsExtra 似乎可以解决问题,但我不明白为什么.
Installing xtsExtra seems to solve the problem, but I don't understand why.
推荐答案
xts::plot.xts
指定构建坐标轴时的几个参数(col
, lwd
、las
和 mgp
),但它也将 ...
传递给 axis
打电话.例如:
xts:::plot.xts
specifies several parameters when constructing the axes (col
, lwd
, las
, and mgp
), but it also passes ...
to the axis
call. For example:
axis(1, at = xycoords$x, labels = FALSE, col = "#BBBBBB", ...)
col
已经指定,所以如果你也指定它,它会通过 ...
传递给 axis
,现在有两个指定给 axis
调用的 col
参数.
col
is already specified, so if you specify it also, it gets passed to axis
via ...
and now there are two col
arguments specified to the axis
call.
这不是 xtsExtra::plot.xts
的问题,因为那些参数在 ...
之前从 ...
中删除> 传递给 axis
调用.
This isn't a problem with xtsExtra:::plot.xts
because those parameters are removed from ...
before ...
is passed to the axis
call.
这篇关于绘制 xts 对象 - 传递 lwd 和 col 参数的值会产生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!