HES 505 Fall 2023: Session 31
Static
Interactive
Dynamic
Identifying structure that might otherwise be hidden
Diagnosing models and interpreting results
Aiding the sense-making process
Zooming allows the user to determine scale of presentation
Hovering allows more information to be displayed ‘on-demand’
Subsetting facilitates ease of interpretation
Your advisor and colleagues?
An external collaborator?
The general public?
Feedback is critical
Ideation: What specifically does the user need?
Meaning: Are the data clearly defined and explained? Are the conclusions obvious?
Function: Given the usecases, will the application (visualization) actually perform?
API: Application Programming Interface
A software intermediary that allows two applications to “communicate”
Lots of R
packages rely on APIs to access data on the web (e.g.,tidycensus
)
Facilitates reproducibility and powerful web applications built on R
analyses
May require “keys” and additional parsing (Mapbox and Google)
mapview
and tmap
Easy extension of your existing
Class Demo
plotly
Syntax is similar to ggplot
hoverinfo
describes which elements you’d like to make interactive
Other plot elements available (see ?plot_ly
)
plotly
g <- txhousing %>%
# group by city
group_by(city) %>%
# initiate a plotly object with date on x and median on y
plotly::plot_ly(x = ~date, y = ~median) %>%
# add a line plot for all texan cities
plotly::add_lines(name = "Texan Cities", hoverinfo = "none",
type = "scatter", mode = "lines",
line = list(color = 'rgba(192,192,192,0.4)')) %>%
# plot separate lines for Dallas and Houston
plotly::add_lines(name = ~city,
data = filter(txhousing,
city %in% c("Dallas", "Houston")),
hoverinfo = ~city,
line = list(color = c("red", "blue")),
color = ~city)
tmap
and gganimate
::: columns ::: {.column width=“40%”}
::: ::: {.column width=“60%”}