Reputation: 5817
I just want to set the line width of the line I'm plotting to be of a certain value. The rest (gridlines, border around graph) should remain 1.0 of width.
But if I set par(lwd=2)
all lines are wider. If I set plot.xts(AAPL,lwd=2)
, I get an error:
Error in axis(1, at = xycoords$x[ep], labels = names(ep), las = 1, lwd = 1, :
formal argument "lwd" matched by multiple actual arguments
Heres my code:
library(quantmod)
getSymbols("AAPL")
par(lwd=2)
plot.xts(AAPL)
Upvotes: 3
Views: 3899
Reputation: 8403
My solution to this to pass type='n'
and then call lines
:
require(quantmod)
getSymbols('CPIAUCSL',src='FRED')
xts::plot.xts(CPIAUCSL, type='n')
lines(CPIAUCSL, lwd=3, col='darkgoldenrod')
This does not require the xtsExtra
package, which makes other changes and is (maybe) not being actively maintained. (At least it doesn't install via the package manager, today, on R 3.1.1.)
Upvotes: 2
Reputation: 17189
Try using xtsExtra
from R-Forge. It has lot of enhancement for plotting xts objects.
install.packages("xtsExtra", repos="http://R-Forge.R-project.org")
You can use
library(xtsExtra)
getSymbols("AAPL")
plot.xts(AAPL[,4], lwd = 2)
That will give you
Upvotes: 1