Series Colors

You can specify an alternate color palette for series lines using the colors option. For example, to choose a palette from RColorBrewer:

lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(3, "Set2"))

Step Plots

By default dygraphs displays series as a line, you can however plot series as step chart as follows:

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(stepPlot = TRUE)

Filling

You can also fill in the area underneath the series as well as customize the alpha value for the filling:

dygraph(ldeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(fillGraph = TRUE, fillAlpha = 0.4)

Point Display

You can include display of the individual points in a series as well as customize the size of the points:

dygraph(ldeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(drawPoints = TRUE, pointSize = 2)

Different point shapes are available as well:

dygraph(ldeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyOptions(drawPoints = TRUE, pointSize = 5, pointShape = "triangle")

The possible parameters for pointShape are: triangle, square, diamond, pentagon, hexagon, circle, star, plus or ex.

Per-Series Options

All of the options above can also be set on a per-series basis using the dySeries function. For example:

dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("mdeaths", drawPoints = TRUE, pointShape = "square", color = "blue") %>%
  dySeries("fdeaths", stepPlot = TRUE, fillGraph = TRUE, color = "red")

Note that you can specify colors globally (as demonstrated above) or per-series, but you cannot mix both styles of assigning colors.

Line Strokes

You can also customize the way that series lines are drawn. Here we draw a wider line with a custom stroke pattern (dashed line):

dygraph(ldeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("V1", strokeWidth = 2, strokePattern = "dashed")

dyGroup

With dyGroup you can replicate options across multiple series or pass a vector of values and have it replicate across the series. If arguments differ in length than the number of series named, then the argument will be cycled across the named series.

lungDeaths <- cbind(mdeaths, fdeaths, ldeaths)

dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dySeries("fdeaths", stepPlot = TRUE, color = "red") %>% 
  dyGroup(c("mdeaths", "ldeaths"), drawPoints = TRUE, color = c("blue", "green"))
Fork me on GitHub