-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add ylab to plot.xts #334
Add ylab to plot.xts #334
Conversation
Few things worth mentioning: 1. Tried to do this in chart.lines() but ylab was not passing through 2. Need a solution for when multi.panel is not NULL, perhaps a character vector of ylab strings? 3. Needed the plot printed before i could add title() hence cs becomes plot(cs) Simple test is add ylab argument to plot.xts() See joshuaulrich#333
I should mention i did try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At minimum, the hasArg()
bug needs to be fixed. We also should not force the plot to be rendered. That's what all the expression logic and chart.lines()
accomplish.
This seems to work for me. Can you try it and see if it does what you expect? diff --git a/R/plot.R b/R/plot.R
index 01474a3..11b6fcc 100644
--- a/R/plot.R
+++ b/R/plot.R
@@ -286,6 +286,7 @@ plot.xts <- function(x,
cs$Env$column_names <- colnames(x)
cs$Env$nobs <- NROW(cs$Env$xdata)
cs$Env$main <- main
+ cs$Env$ylab <- if (hasArg("ylab")) eval.parent(plot.call$ylab) else ""
# Set xlim using the raw returns data passed into function
# xlim can be based on observations or time
@@ -411,6 +412,10 @@ plot.xts <- function(x,
col=theme$labels, srt=theme$srt, offset=1, pos=4,
cex=theme$cex.axis, xpd=TRUE)))
}
+
+ # ylab
+ exp <- c(exp, expression(title(ylab = ylab[1], mgp = c(1, 1, 0))))
+
cs$add(exp, env=cs$Env, expr=TRUE)
# add main series |
Thanks Josh. Is there a way for me to pull your changes, or must i add them manually? |
I can push them to your branch if they look good to you.
|
Thanks Josh, it works. Feel free to push. |
This reverts commit 3e92c99.
I just noticed your comment about how to handle when |
Later is fine. I have pulled your changes, thanks. It seems the PR is updated with your changes. Is there anything left for me to do on the PR? |
Nothing more for you to do. I just needed to merge. Thanks for this suggestion and feedback! |
Thank you Josh. |
Few things worth mentioning:
Simple test is add ylab argument to plot.xts()
See #333
Please review the contributing guide before submitting your pull request. Please pay special attention to the pull request and commit message sections. Thanks for your contribution and interest in the project!