Add a data series group to a dygraph plot. Note that options will use the default
global setting (as determined by dyOptions
) when not specified
explicitly. Importantly, any dySeries options passed can be passed as a vector of values
and will be replicated across all series named as part of the group. If arguments differ in
length than the number of series named, then the argument vector will be
cycled across the named series.
dyGroup(dygraph, name = NULL, label = NULL, color = NULL, axis = "y",
stepPlot = NULL, stemPlot = NULL, fillGraph = NULL, drawPoints = NULL,
pointSize = NULL, pointShape = NULL, strokeWidth = NULL,
strokePattern = NULL, strokeBorderWidth = NULL,
strokeBorderColor = NULL, plotter = NULL)
Dygraph to add a series definition to
character vector of the series within data set. If no name is specified then series are bound to implicitly based on their order within the underlying time series object. This parameter can also be a character vector of length 3 that specifies a set of input column names to use as the lower, value, and upper for a series with a shaded bar drawn around it.
Labels to display for series (uses name if no label defined)
Color for series. These can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow", etc. If not specified then the global colors option (typically based on equally-spaced points around a color wheel).
Y-axis to associate the series with ("y" or "y2")
When set, display the graph as a step plot instead of a line plot.
When set, display the graph as a stem plot instead of a line plot.
Should the area underneath the graph be filled? This option is not compatible with error bars.
Draw a small dot at each point, in addition to a line going through the point. This makes the individual data points easier to see, but can increase visual clutter in the chart.
The size of the dot to draw on each point in pixels. A dot is always drawn when a point is "isolated", i.e. there is a missing point on either side of it. This also controls the size of those dots.
The shape of the dot to draw. Can be one of the following: "dot" (default), "triangle", "square", "diamond", "pentagon", "hexagon", "circle", "star", "plus" or "ex".
The width of the lines connecting data points. This can be used to increase the contrast or some graphs.
A predefined stroke pattern type ("dotted", "dashed", or
"dotdash") or a custom pattern array where the even index is a draw and odd
is a space in pixels. If NULL
then it draws a solid line. The array
should have an even length as any odd length array could be expressed as
a smaller even length array.
Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines.
Color for the line border used if
strokeBorderWidth
is set.
A function which plots the series group. See the dygraphs documentation for additional details on plotting functions.
Dygraph with additional series
NOTE: dyGroup will turn off stackedGraph
, as the option will calculated cumulatives using
all series in the underlying dygraph, not just a subset.
The dyGroup function can also replicated similar arguments across multiple series, or be used to apply a grouped custom plotter - i.e., multi-column plotter - to a subset of the dygraph data series.
# NOT RUN {
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dySeries("fdeaths", stepPlot = TRUE, color = "red") %>%
dyGroup(c("mdeaths", "ldeaths"), drawPoints = TRUE, color = c("blue", "green"))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab