Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to remove time range from plot title #247

Closed
joshuaulrich opened this issue Jun 15, 2018 · 1 comment
Closed

Allow users to remove time range from plot title #247

joshuaulrich opened this issue Jun 15, 2018 · 1 comment
Labels
enhancement Enhancement to existing feature plot
Milestone

Comments

@joshuaulrich
Copy link
Owner

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 be TRUE by default, and the user could set it to FALSE and/or a format (e.g. "%Y-%m-%d")?

@joshuaulrich joshuaulrich added enhancement Enhancement to existing feature plot labels Jun 15, 2018
@joshuaulrich
Copy link
Owner Author

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")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to existing feature plot
Projects
None yet
Development

No branches or pull requests

1 participant