• Visualization for Data Science with R
  • About This Book
    • Proposal
      • Why read this book
      • Structure of the book
      • Software information and conventions
    • About the Author
  • Introduction
    • Outline
  • 1 Overview of common visualizations and how to read them
    • 1.1 Visualization components
    • 1.2 Bar Chart
      • 1.2.1 Variations
      • 1.2.2 Add a variable: Bar charts with color
    • 1.3 Scatter Plot
      • 1.3.1 Variations
      • 1.3.2 Add a variable: Scatter plot with color
      • 1.3.3 Add a variable: Bubble chart
    • 1.4 Line Chart
      • 1.4.1 Using circles to highlight the position of the data points
      • 1.4.2 Using colors to distinguish individual lines
      • 1.4.3 Variations
      • 1.4.4 Add a variable: Line chart with color
    • 1.5 Pie Chart
      • 1.5.1 Variations
      • 1.5.2 Add a variable: Small multiples
    • 1.6 Heat Map
      • 1.6.1 Variations
      • 1.6.2 Add a variable: Bubble matrix
    • 1.7 Histogram
      • 1.7.1 Variations
      • 1.7.2 Add a variable: Separate groups on x axis
      • 1.7.3 Add a variable: Separate groups with color
    • 1.8 Maps
      • 1.8.1 Choropleth
      • 1.8.2 Proportional Symbol Map
  • 2 Building basic visualizations with ggplot2
    • 2.1 Basic ggplot2 syntax
      • 2.1.1 Simple Plot Template
    • 2.2 Example: Vineyards in the Finger Lakes Region of New York State
      • 2.2.1 Step 1: Add Main Plot Function
      • 2.2.2 Step 2: Set the Data
      • 2.2.3 Step 3: Choose a shape layer
      • 2.2.4 Step 4: Map Variables to Aesthetics
      • 2.2.5 Step 5: Adjust the Defaults
    • 2.3 Inheritance
    • 2.4 How to Debug Code
  • 3 Working with textual data in ggplot2
    • 3.1 What is a text variable?
    • 3.2 Visualizing text variables
      • 3.2.1 Common mappings for text variables
      • 3.2.2 Ordering
      • 3.2.3 Long Text Labels
      • 3.2.4 Picking Colors
      • 3.2.5 Small Multiples
  • 4 Customizing the design of ggplot2 visualizations
    • 4.1 Common Data Modifications
    • 4.2 Labels
    • 4.3 Scales
    • 4.4 Themes
  • 5 Avoiding unethical design practices
    • 5.1 Due Diligence for Analysis
    • 5.2 Promote Dignity and Agency
    • 5.3 Reduce Distortion
      • 5.3.1 Color
      • 5.3.2 Shapes
      • 5.3.3 Truncated Axes
    • 5.4 Compare Like Things
      • 5.4.1 Dual Axis
      • 5.4.2 Normalizing Raw Data
    • 5.5 Be True to the Data
      • 5.5.1 Don’t Cherry-Pick Data
      • 5.5.2 Matching Data With Chart Type
      • 5.5.3 Beware of Conflicts of Interest
      • 5.5.4 Check if subsets exhibit different patterns (Simpson’s Paradox)
      • 5.5.5 Careful Binning
    • 5.6 Proper Citation and Documentation
      • 5.6.1 Transparent Practices
  • 6 Building ggplot2 visualizations into print publications
    • 6.1 Exporting ggplot2 Visualizations
    • 6.2 Using RMarkdown to create PDF reports
    • 6.3 Using R Packages to Build Word and PowerPoint Files
  • 7 Basic accessibility for static visualizations
    • 7.1 Accessible Text Accompanying the Visualization
    • 7.2 Neurodivergence
    • 7.3 Low Vision
    • 7.4 Color Vision Deficiency
      • 7.4.1 Dual encoding (never just color)
      • 7.4.2 Color palettes
    • 7.5 Screen Reader Users
      • 7.5.1 Alternative Text
      • 7.5.2 Longer Descriptions
      • 7.5.3 Converting graphics to sound, touch, text, table
    • 7.6 Accessibility Resources
  • 8 Exploring interactivity in visualizations with plotly and crosstalk
    • 8.1 Interactivity for Exploration
    • 8.2 Interactive Components
      • 8.2.1 About Websites and HTML
      • 8.2.2 Simple Markdown Websites
    • 8.3 HTML Widgets
      • 8.3.1 Plotly
      • 8.3.2 DataTables
    • 8.4 CrossTalk
  • 9 Using RMarkdown to build websites for projects
    • 9.1 Static Websites
    • 9.2 Hosting
    • 9.3 Associating a Website with an R Project
  • 10 Using RMarkdown to build dashboards for projects
    • 10.1 What is a dashboard?
    • 10.2 Using flexdashboards to arrange components
    • 10.3 Blending Crosstalk with Flexdashboards
    • 10.4 Basic Dashboard Design
  • 11 Basic usability for interactive visualizations
    • 11.1 What do users want to do with a dashboard
      • 11.1.1 Conducting an Initial User Study
    • 11.2 How to Test a Dashboard
      • 11.2.1 Preliminary Questions
      • 11.2.2 5-second test for first impressions
      • 11.2.3 Think-aloud Scenarios
      • 11.2.4 Closing Questions
  • 12 Teacher’s guide
    • 12.1 Live Coding
    • 12.2 Sample Data
  • Appendix
  • A Datasets
    • Duke Enrollment
      • Bar Chart
    • Coral Resilience Data
    • Git Experience
    • Inclusiveness Index
    • Candidate Demographics
    • Affinity Spending
    • Vineyards
  • References
  • Published with bookdown

Visualization for Data Science with R

Chapter 6 Building ggplot2 visualizations into print publications

6.1 Exporting ggplot2 Visualizations

6.2 Using RMarkdown to create PDF reports

6.3 Using R Packages to Build Word and PowerPoint Files