Assignment 4: Visualization Deep Dive

Due by 11:59 PM on Sunday, May 3, 2026

NoteAssignment Details

Assigned: Monday, April 27 (Session 9) Due: Sunday, May 3 at 11:59 PM Submit: Quarto document (.qmd) AND rendered HTML on Canvas

TipGetting started

Overview

This assignment focuses on creating publication-quality visualizations. You’ll practice using different geoms, scales, themes, and design principles.

Setup

# Assignment 4: Visualization Deep Dive
# Your Name
# Date

library(tidyverse)

Part 1: Bar Charts with Error Bars (25 points)

Use the palmerpenguins dataset:

# install.packages("palmerpenguins")
library(palmerpenguins)

Task 1.1

Create a summary table showing mean flipper length by species, including standard error.

# Hint: SE = sd / sqrt(n)

Task 1.2

Create a bar chart showing mean flipper length by species with error bars representing ±1 SE.

Your plot should:

  • Have clear axis labels (not variable names)
  • Use a clean theme
  • Have a descriptive title
  • Use a colorblind-friendly palette (hint: scale_fill_viridis_d())

Part 2: Distributions (25 points)

Task 2.1

Create a histogram of penguin body mass. Experiment with different bin widths. In a comment, explain what bin width you chose and why.

Task 2.2

Create overlapping density plots of body mass, colored by species. Set transparency so all distributions are visible.

Task 2.3

Create a boxplot of body mass by species. Then recreate it as a violin plot. In a comment, discuss what each shows that the other doesn’t.

Part 3: The “Bad” and “Good” Graph (25 points)

Using any dataset of your choice (mpg, penguins, diamonds, etc.):

Task 3.1: The Bad Graph

Create an intentionally bad visualization that violates at least 4 design principles. In comments, list what makes it bad.

Examples of “bad” choices:

  • 3D effects
  • Pie chart with many categories
  • Rainbow color scheme
  • Missing labels
  • Misleading axis
  • Excessive chartjunk

Task 3.2: The Good Graph

Create a good version of the same data. In comments, explain your design choices.

Part 4: Recreate a Figure (15 points)

This task uses data from a real psychology study on partisan bias in news evaluation. Participants were assigned to one of three teams (Team Spain, Team Greece, or No Team) and read news statements slanted toward one side or the other. The outcome is an acceptance threshold (c) from signal detection theory — higher values mean the participant required stronger evidence before accepting a statement as true.

Download partisan_bias.csv from Canvas and save it in your data/raw/ folder. The file has four columns:

Column Description
participant_id Unique participant identifier
team Group assignment: 1 = Team Spain, 2 = Team Greece, 3 = No Team
SP_c Acceptance threshold for Pro-Spain statements
GR_c Acceptance threshold for Pro-Greece statements

Task 4.1

Import the data and convert team from a number to a factor with labels “Spain”, “Greece”, and “No Team” (in that order).

Task 4.2

Recreate Figure 3 from the paper (provided on Canvas) as closely as you can. Pay attention to:

  • Geom type and positioning
  • Error bars
  • Axis labels and legend title
  • Theme

You won’t match it exactly — plain text axis labels are fine.

Grading Rubric

Component Points
Part 1: Bar charts with error bars 25
Part 2: Distributions 25
Part 3: Bad and Good graph 25
Part 4: Recreate a figure 15
Code runs without errors 10
Total 100

Submission

Submit:


NotePSY 510 (Graduate Students)

Students enrolled in PSY 510 must complete the following extension in addition to all tasks above.

Graduate Extension: Publication-Ready Figure

Creating figures for a course assignment and creating figures for a manuscript are different tasks. Journals specify file format, resolution, and dimensions, and reviewers expect a caption that stands on its own without the surrounding text.

Task G.1

Choose the figure you’re most proud of from Parts 1–3. Look up the author guidelines for one real journal in your area (Psychological Science, JPSP, Emotion, or similar) and save the figure at 300 dpi with dimensions matching their specifications.

# Example — adjust width/height to your target journal's specs:
ggsave("publication_figure.tiff",
       plot  = my_plot,
       width = 3.5, height = 3,
       units = "in", dpi = 300)

Task G.2

Write a figure caption in APA style — the kind you would include in a manuscript. It should describe what the figure shows, define any abbreviations, and state what the error bars represent (if applicable). Refer to the APA figure guidelines handout from Session 16.

Include the caption as a comment directly above your ggsave() call.

Task G.3

In 3–5 sentences (as a comment), justify your design choices: Why this geom? Why this color palette? What did you deliberately remove or simplify? Connect your reasoning to the perception and design principles from Session 9.

Submission: Add ggsave(), the caption, and the justification to your .qmd file under a clearly marked ## Graduate Extension section. Submit the saved figure file alongside your .qmd and HTML.