Professional Data Visualization

Beyond Basic ggplot2

Why Professional Data Visualization?

Moving from “making plots” to “effective communication”:

  • Process vs. Product: Teaching students to evaluate their own work
  • Advanced techniques: Extensions, theming, interactivity
  • Professional standards: Publication-ready graphics
  • Assessment strategies: Clear grading principles

Learning Objectives

By the end of this session, you will:

  1. Understand grading principles for “good” data visualization (process vs. product)
  2. Know current ggplot2 extensions and advanced theming techniques
  3. Be familiar with interactive visualization tools (plotly, htmlwidgets)

Focus: Comprehensive resources to teach professional data visualization

Grading Principles

Process vs. Product Assessment

Teaching visualization requires evaluating:

  • Process: Design thinking, iteration, justification
  • Product: Technical execution, clarity, aesthetics
  • Reflection: Understanding of design choices
  • Critique: Ability to evaluate others’ work

Goal: Students learn to self-assess, iterate, and improve

What Makes a “Good” Visualization?

Technical Accuracy:

  • Appropriate chart type for data
  • Correct use of scales and axes
  • Accurate representation of relationships

Design Principles:

  • Clear, informative titles and labels
  • Appropriate color choices and accessibility
  • Effective use of visual hierarchy
  • Minimal cognitive load

Communication:

  • Clear message or insight
  • Appropriate for target audience
  • Context and interpretation provided

Grading Rubric for Visualizations

After considering some of the principles of “good” viz, what features should we be grading for?

What message do we want to tell by the rubric?

Take just 60 seconds to consider what elements would go into the rubric.

01:00

Example Grading Rubric Framework

Criteria Excellent (4) Good (3) Needs Work (2) Poor (1)
Chart Type Match for data & message Appropriate choice Questionable fit Wrong choice
Design Polished, clean, accessible Good design principles Some issues Many problems
Message Compelling insight Good communication Unclear message No clear point
Process Shows iteration/ reflection Evidence of thinking Some documentation No process shown

Teaching Tip: Have students grade example visualizations using your rubric before using it on their own work

Sometimes Bad Is The Way

Sometimes Bad Is The Way

Challenge students to create a data visual that does well in only one of the 4 criteria

  • Can encourage them to think through the criteria without being too routine or safe
  • Sharing within the class (e.g., on the class message board) can expand the learning
  • Ask the students which ceriteria it appears to do well
  • If a little competition makes sense: vote for best of the bad

Teaching Resources

Rubric Examples:

Design Principle Resources:

  • Alberto Cairo’s “The Truthful Art” - Comprehensive visualization principles
  • Edward Tufte’s principles - Classic design guidelines
  • Claus Wilke’s “Fundamentals of Data Visualization” - Modern, R-focused approach

Teaching Examples:

ggplot2 Extensions

The Extension Ecosystem

ggplot2 is designed to be extensible:

  • 50+ extension packages for specialized needs
  • Consistent grammar across extensions
  • Professional-quality output
  • Active development community

Teaching advantage: Students learn one grammar, unlock dozens of tools

Essential Extensions for Teaching

# Install key extensions
# pak::pak(c("patchwork", "gganimate", "ggtext", "plotly",
#            "ggforce", "ggh4x", "ggrepel", "palmerpenguins"))

# Core packages
library(ggplot2)
library(palmerpenguins)
library(patchwork)  # Combining plots
library(gganimate)  # Animations  
library(ggtext)     # Enhanced text
library(plotly)     # interactive plots

Patchwork: Combining Plots

# Create individual plots
p1 <- ggplot(penguins, aes(bill_length_mm, body_mass_g, color = species)) + 
  geom_point()

p2 <- ggplot(penguins, aes(species)) + 
  geom_bar()

p3 <- ggplot(penguins, aes(body_mass_g)) + 
  geom_histogram()

# Combine with operators
(p1 + p2) / p3    # Side by side and stacked 

Teaching value: Students learn composition principles and complex figure creation for publications

gganimate: Bringing Data to Life

library(gapminder)

# Create animated plot
ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent)) +
  geom_point(alpha = 0.7) +
  scale_x_log10() +
  # Animation components
  transition_time(year) +
  labs(title = "Year: {closest_state}")

Student Exercise: Create before/after static vs. animated versions to show communication differences

ggtext: Professional Text Formatting

library(ggtext)

ggplot(penguins, aes(bill_length_mm, body_mass_g, color = species)) +
  geom_point() +
  labs(
    title = "Bill length vs. **Body mass**",
    subtitle = "Data colored by <span style='color:blue;'>penguin species</span>",
    caption = "*Source: Palmer Station Antarctica LTER*"
  ) +
  theme(
    plot.title = element_markdown(),
    plot.subtitle = element_markdown(),
    plot.caption = element_markdown()
  )

Advanced Theming Techniques

# Custom theme for consistency
my_theme <- theme_minimal() +
  theme(
    text = element_text(family = "Arial"),
    plot.title = element_text(size = 16, face = "bold"),
    panel.grid.minor = element_blank(),
    legend.position = "bottom"
  )

# Apply to all plots
theme_set(my_theme)

Teaching Strategy: Have students develop their own theme as a semester project

ggplot2 Extension Teaching Resources

Comprehensive Guides:

Package-Specific Resources:

Teaching Materials:

Interactive Visualization

Why Interactive Visualization?

Interactive plots enable:

  • Exploration: Users can discover patterns themselves
  • Engagement: More compelling than static plots
  • Detail: Tooltips and zoom for complex data
  • Storytelling: Guided narratives through data

Teaching opportunity: Students learn both exploration and communication

The htmlwidgets Ecosystem

# Install interactive packages
# pak::pak(c("plotly", "DT", "leaflet", "ggiraph"))

# Core interactive tools
library(plotly)     # Interactive plots
library(DT)         # Interactive tables
library(leaflet)    # Interactive maps
library(ggiraph)    # Interactive ggplot2

htmlwidgets: R bindings to JavaScript libraries that work in multiple contexts (console, RStudio, Rmarkdown, Shiny)

From ggplot2 to plotly

# Create ggplot
p <- ggplot(penguins, aes(bill_length_mm, body_mass_g, 
             color = species, text = paste("Species:", species))) +
  geom_point(size = 3) +
  labs(title = "Bill Length vs. Body Mass")

# Make it interactive
ggplotly(p, tooltip = "text")

Custom plotly Interactions

# Native plotly syntax
plot_ly(penguins, x = ~bill_length_mm, y = ~body_mass_g, color = ~species,
        text = ~paste("Species:", species), 
        hovertemplate = "%{text}<br>Bill Length: %{x}mm<br>Body Mass: %{y}g") %>%
  add_markers(size = ~bill_depth_mm) %>%
  layout(title = "Interactive Penguin Data",
         xaxis = list(title = "Bill Length (mm)"),
         yaxis = list(title = "Body Mass (g)"))

ggiraph: Interactive ggplot2

library(ggiraph)

# Add interactivity to ggplot2
p <- ggplot(penguins, aes(bill_length_mm, body_mass_g, 
             tooltip = paste("Species:", species),
             data_id = species)) +
  geom_point_interactive(aes(color = species), size = 3) +
  theme_minimal()

# Render as interactive
girafe(ggobj = p)

Student-Friendly: Uses familiar ggplot2 syntax with _interactive suffix

Interactive Visualization Teaching Resources

Comprehensive Learning:

htmlwidgets Ecosystem:

Teaching-Specific Resources:

Integration Examples:

  • Saving and embedding HTML widgets in reports
  • Using interactive plots in Rmarkdown documents
  • Combining multiple widgets for dashboards

Course Integration Strategies

Scaffolded Learning Approach:

  1. Week 1-2: ggplot2 fundamentals and design principles
  2. Week 3-4: Extensions (patchwork, themes, ggtext)
  3. Week 5-6: Animation with gganimate
  4. Week 7-8: Interactive visualization with plotly

Assessment Progression:

  • Start with static plot improvement exercises
  • Move to extension-based enhancement projects
  • Culminate with interactive storytelling assignments
  • Portfolio showing evolution from basic to professional

Professional Development Resources

Visualization Theory & Principles:

R-Specific Advanced Techniques:

Teaching Methodology: