How do you create a bar and line plot with R dygraphs?

前端 未结 3 1647
情书的邮戳
情书的邮戳 2020-12-06 13:49

I would like to create a bar and line chart using dygraphs, which seems like it should be possible based on the \"Bar & Line Chart\" dygraphs example here, and the

3条回答
  •  温柔的废话
    2020-12-06 14:30

    I am not sure this is exactly what you want. What I propose, comes close to the combination of a bar plot and a line plot, without the need to create a separate function.

    You can set the type of plot per series, with dySeries. You can choose between lineplot (default), stepPlot, and stemPlot. In addition you may set to see the points with drawPoints and pointSize, you may also opt to fill the graph or not with fillGraph. For other options type ?dySeries

    The code looks as follows:

    library(dygraphs)
    
    lungDeaths <- cbind(ldeaths, mdeaths)
    
    dygraph(lungDeaths, main = "Main Title") %>%
      dySeries("ldeaths", drawPoints = FALSE) %>%
      dySeries("mdeaths", stepPlot = TRUE, fillGraph = TRUE)
    

    Yielding this plot:

    Please, let me know whether this is what you want.

提交回复
热议问题