Add a data series to a dygraph plot. Note that options will use the default
global setting (as determined by dyOptions
) when not specified
explicitly. When no dySeries
is specified for a plot then all series
within the underlying data are plotted.
dySeries(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
Name of 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.
Label 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 data series. May also be set on on
a global basis using dyOptions
. See the
dygraphs documentation for
additional details on plotting functions.
Dygraph with additional series
# NOT RUN {
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dySeries("mdeaths", drawPoints = TRUE, color = "blue") %>%
dySeries("fdeaths", stepPlot = TRUE, color = "red")
# }
Run the code above in your browser using DataLab