Closed joshuaulrich closed 2 years ago
This answer on StackOverflow shows how to always remove the date range. Here's the relevant code from the answer:
plotxts <- fix("plot.xts")
# In the editor that opens, replace the lines below:
### text.exp <- c(expression(text(xlim[1], 0.5, main, font = 2,
### col = theme$labels, offset = 0, cex = 1.1, pos = 4)),
### expression(text(xlim[2], 0.5, paste(start(xdata[xsubset]),
### end(xdata[xsubset]), sep = " / "), col = theme$labels,
### adj = c(0, 0), pos = 2)))
### cs$add(text.exp, env = cs$Env, expr = TRUE)
# with these lines:
### text.exp <- expression(text(xlim[1], 0.5, main, font = 2,
### col = theme$labels, offset = 0, cex = 1.1, pos = 4))
# Finally, you need to ensure your copy's environment is the xts namespace:
environment(plotxts) <- asNamespace("xts")
A plot of an xts object always contains the timespan to the right of the main title. There is currently no way to omit the range from the title. Several users have asked how to remove it, so there needs to be a way to accomplish that.
My first thought is that we omit the timespan if the user provides a value for
main
. But what if they want a custom title and the timespan?Maybe we add a
main.range
argument? It could beTRUE
by default, and the user could set it toFALSE
and/or a format (e.g."%Y-%m-%d"
)?