ETC5523: Communicating with Data

Interactive

Lecturer: Emi Tanaka

Department of Econometrics and Business Statistics



Aim

  • Gain exposure to existing state-of-the-art interactive graphics
  • Understand the difference between interactivity in Shiny and say, Plotly graphics

User Interactions

Image from Spencer (2022, Feb. 17). Data in Wonderland. Retrieved from https://ssp3nc3r.github.io/data_in_wonderland

User Inputs

Image from Spencer (2022, Feb. 17). Data in Wonderland. Retrieved from https://ssp3nc3r.github.io/data_in_wonderland

Overview

Image from Spencer (2022, Feb. 17). Data in Wonderland. Retrieved from https://ssp3nc3r.github.io/data_in_wonderland

State of the art for
interactive plots

Interactive plots with JS

  • State-of-the-art for interactive plots is JS
  • Some of the most popular and free JS library for plotting are:
  • Rising JS libraries that are based on the Grammar of Graphics:

Interactive plots with JS through R

  • No need to learn JS!
  • Many JS library for plotting are available via an R package:
JS R package
Chart.js chartjs, charter
Dygraphs dygraphs
D3.js r2d3, networkD3
ECharts echarts4r
Google Charts googleVis
Highcharts highcharter
Plotly plotly
Vis.js visNetwork
Observable Plot obsplot
Vega and Vega-Lite vegawidget, altair, virgo, vegabrite

Plotly

Plotly

  • Plotly is a high-level, declarative library for plotting build on d3.js and stack.gl (open software ecosystem for WebGL).
library(plotly)
plot_ly(ggplot2::diamonds, x = ~cut, color = ~clarity, colors = "Accent")

Plotly for ggplot2

library(ggplot2)
g <- ggplot(ggplot2::diamonds, aes(x = cut, fill = clarity)) +
  geom_bar(position = "dodge") +
  scale_fill_brewer(palette = "Accent")

ggplotly(g)

Plotly with drop down menu