# How To Plot With Dygraphs: Exercises

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**INTRODUCTION**

The dygraphs package is an R interface to the dygraphs JavaScript charting library. It provides rich facilities for charting time-series data in R, including:

**1**. Automatically plots xts time-series objects (or any object convertible to xts.)

**2**. Highly configurable axis and series display (including optional second Y-axis.)

**3**. Rich interactive features, including zoom/pan and series/point highlighting.

**4**. Display upper/lower bars (ex. prediction intervals) around the series.

**5**. Various graph overlays, including shaded regions, event lines, and point annotations.

**6**. Use at the R console, just like conventional R plots (via RStudio Viewer.)

**7**. Seamless embedding within R Markdown documents and Shiny web applications.

Before proceeding, please follow our short tutorial.

Look at the examples given and try to understand the logic behind them. Then, try to solve the exercises below by using R without looking at the answers. Then, check the solutions to check your answers.

**Exercise 1**

Unite the two time series data-sets `mdeaths`

and `fdeaths`

and create a time-series dygraph of the new data-set.

**Exercise 2**

Insert a date range selector into the dygraph you just created.

**Exercise 3**

Change the label names of “mdeaths” and “fdeaths” to “Male” and “Female.”

**Exercise 4**

Make the graph stacked.

**Exercise 5**

Set the date range selector height to 20.

**Exercise 6**

Add a main title to your graph.

**Exercise 7**

Use the tutorial’s predicted data-set to create a dygraph of “lwr”, “fit”, and “upr”, but display the label as the summary of them.

**Exercise 8**

Set the colors to red.

**Exercise 9**

Remove the x-axis grid lines from your graph.

**Exercise 10**

Remove the y-axis grid lines from your graph.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.