-
-
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
plot.xts ignores col.up and col.dn for type="h" #224
Comments
I think the central problem is that we set default values for non-user-specified arguments too early. We currently set default values before we create the expression that will be evaluated to create the plot. Instead, we should wait to set default values until the expression that creates the plot is evaluated. This is a good general rule for all In this specific case, we need to delay setting values for |
I agree that we could do a better job of setting default values, but deciding when imposes an implicit time dependency which could make things more complicated. My preference is for an approach with a simple set of rules. The |
Can you clarify what you mean by "implicit time dependency"? I think your preferred solution would be a fine patch to get this working again. Go ahead and give it a shot. |
Arguments passed in from the function are just that, arguments, whether they have the default values or user specified values. They live in the |
My point was that we "set" many values when we build the call to exp <- quote(chart.lines(xdata, type=type, lty=lty, lwd=lwd, lend=lend,
col=theme$col, up.col=theme$up.col, dn.col=theme$dn.col,
legend.loc=legend.loc)) So the values for |
This issue requires 2 fixes:
For the second point, we need to handle 3 cases (assuming
|
- The up.col and dn.col arguments are only relevant for histogram plots with type="h" so those should supersede the col argument. - The default values for up.col and dn.col changed to NULL so that we only use those values for coloring the histogram chart if they are specified. This allows for a simple rule to use different up and down colors when specified, otherwise use the col argument. - Note that we still have the problem of recycling colors. Will fix that in a separate commit. see #224
- We need to be aware of the length of the color vector that is passed in the case of type="h". If the length of the vector is less than the number of elements in x, then R will recycle the colors. This is not the behavior we want. - To fix this, I added a simple check of the length of the color vector and number of observations of x. If the color vector has fewer elements than the number of observations, then we only use the first element from the color vector. see #224
Merged to master, closing as fixed. |
Description
When plotting a histogram,
plot.xts
does not respect the up.col and dn.col arguments, instead it always seems to take the color from the col argument.Minimal, reproducible example
The text was updated successfully, but these errors were encountered: