1. Web-friendly visualizations
In the last lesson we saw some of the challenges with using static graphs. Now we're going to talk about "web-friendly" visualization approaches that will behave well in dashboards.
2. What is web-friendly?
So, what is a web-friendly graphic? It's one that is dynamic and often has interactive components. It will resize appropriately as a viewer resizes their browser window. Generally, there is HTML and javascript underlying these graphics, but you don't have to know anything about that to create them.
3. Web-friendly options
There are quite a few R packages that allow you to create web-friendly graphics with R code. Some well known options are listed below. Each has its own set of pros and cons. In this course, we'll focus on the first one, plotly.
4. The magic of plotly
The beauty of plotly is that you don't have to learn any special syntax or ways of making your graphs. If you know how to use ggplot2, you can make web-friendly graphs with plotly. All you have to do is load the plotly package and use the function ggplotly. Then just put your ggplot code inside the ggplotly() function and, like magic, your graph will become web-friendly.
5. Features of plotly graphs
This is what the ggplot we tried to resize looks like after creating it with ggplotly(). Now it fills out the box for the chart, and will re-size appropriately when the browser window is re-sized. Also, take a look at those icons in the upper right. Those are interactive options that allow us to zoom, pan, save the plot as an image, and control how data is displayed when we hover over the bars.
6. Let's practice!
Plotly is a great way to get started with web-friendly graphics. As you progress and discover its limitations, you may wish to learn another package such as Highcharter. But now let's get some hands-on practice with plotly!