Reputation: 2394
I have a bunch of series I'm graphing with dygraphs, but one of the series is special and I bold it
dySeries("meanOfMeans",strokeWidth = 4) %>%
but if I try
dySeries("meanOfMeans",strokeWidth = 4,color = "black") %>%
it turns every line in the graph black. Is there a way to just set one color? Alternatively, is there a way to order the series first? right now the special series is showing up last, which means when the number of series changes, the meanOfMeans falls into a different slot, changing it's color. This is distracting.
If it can just be ordered in the first column, this would be a non-issue, because the color wouldn't change. Note that the series is in the first column in the actual data.table itself, but when I add the dySeries()
line, it moves to the end.
Upvotes: 1
Views: 2938
Reputation: 63
You'll need to specify the color you want for each variable separately with a dySeries command for each.
As specified on page 20 of the dygraph package manual, "global and per-series color specification cannot be mixed." https://cran.r-project.org/web/packages/dygraphs/dygraphs.pdf#page=20
As you found, if you specify only one color, regardless of what series it was specified for, dyGraph will color all of your series accordingly. If you specify some colors, but not all, the colors will not be correct.
As for the ordering of variables, variables will appear on the dygraph according to their dySeries command. When using the stacked version, dyOptions(stackedGraph=TRUE), the variable that is specified first will appear on the top, and the last will appear on the bottom.
I hope this helps :-)
Upvotes: 1