Week 9 β Color & Accessibility
Understanding color theory, palette selection, and accessibility best practices in data visualization.
π Background & Motivation
Color is one of the most powerful and expressive tools in visualization. It can highlight differences, show magnitude, encode categories, or evoke emotionβbut it can also distort, confuse, or exclude if not used carefully. This module explores color theory, perceptual uniformity, and accessibility guidelines to ensure your visuals communicate effectively to all audiences.
We will discuss the use of color in sequential, diverging, and categorical scales, and how to design visualizations that remain interpretable for viewers with color vision deficiencies.
π Learning Objectives
- Distinguish between sequential, diverging, and categorical color schemes.
- Select appropriate palettes based on data type and context.
- Apply color theory concepts (hue, saturation, luminance) to improve legibility.
- Use color tools to ensure accessibility for all users.
- Test visualizations for color blindness and accessibility compliance.
π Readings & Resources
- Fundamentals of Data Visualization β chapters on color and perception.
- ColorBrewer2 β tool for choosing effective color schemes.
- Adobe Color β create custom palettes.
- Coblis β Color Blindness Simulator
- Accessible Data Visualization Guide (W3C)
- Seaborn color palettes documentation
Sample Data Sources:
- Gapminder dataset (for categorical and quantitative mapping)
- U.S. demographic data (for diverging and sequential maps)
- Simulated survey data (for categorical comparison)
π οΈ Setup Checklist
Ensure your environment includes:
pip install seaborn matplotlib colorcet pandas
Confirm you can load sample datasets and apply color palettes using Seaborn and Matplotlib.
π§ Lecture Outline
Session 1 (75 min β Theory Focus)
- Introduction: Why color matters in visualization (10 min)
- Color theory basics β hue, saturation, brightness (15 min)
- Types of color schemes β sequential, diverging, categorical (20 min)
- Color perception & accessibility β common pitfalls (15 min)
- Demonstration: testing palettes with simulators and contrast checkers (15 min)
Session 2 (75 min β Hands-on Focus)
- Experiment with Seaborn and Matplotlib color palettes (20 min)
- Create side-by-side examples: good vs poor palette use (20 min)
- Apply ColorBrewer and Colorcet palettes to the previous weekβs map visualizations (20 min)
- Workshop: redesign one of your past charts for color accessibility (15 min)
π» Starter Notebook Snippets
Using Seaborn palettes
import seaborn as sns
import matplotlib.pyplot as plt
# Sequential palette
sns.palplot(sns.color_palette("Blues", 8))
plt.title("Sequential palette example")
# Diverging palette
sns.palplot(sns.diverging_palette(220, 20, n=8))
plt.title("Diverging palette example")
# Categorical palette
sns.palplot(sns.color_palette("Set2", 8))
plt.title("Categorical palette example")
plt.show()
Applying color palettes to a chart
penguins = sns.load_dataset("penguins").dropna()
sns.scatterplot(data=penguins, x="flipper_length_mm", y="body_mass_g", hue="species", palette="Set2")
plt.title("Categorical color palette example")
plt.show()
Testing color palettes for accessibility
# Example: simulate grayscale or color blindness
import matplotlib.colors as mcolors
import numpy as np
# Convert to grayscale to check luminance contrast
img = np.linspace(0, 1, 256).reshape(1, -1)
plt.imshow(img, cmap="viridis", aspect="auto")
plt.title("Luminance contrast check (Viridis)")
plt.axis('off')
plt.show()
π§ͺ In-Class Activity
- Create 3 mini visualizations (one sequential, one diverging, one categorical) using Seaborn.
- Use ColorBrewer to test and adjust color schemes.
- Simulate color blindness and discuss readability.
- Redesign a prior weekβs map or chart with improved accessibility.
π Homework (Due next Thursday, Oct 30)
- Choose one of your visualizations from a previous week and redesign it to improve color and accessibility.
- Include:
- One before-and-after comparison of color schemes.
- Discussion (150β250 words) of how your new design improves clarity and inclusivity.
- Verification of color accessibility (using simulator or contrast tool).
- Submit
.ipynb
and.html
.
Rubric (10 pts)
- Appropriate use of color schemes (3)
- Accessibility testing and discussion (3)
- Clarity and improvement of redesigned visual (2)
- Reproducibility and documentation (2)
π§© Optional Extensions
- Explore
colorcet
for perceptually uniform colormaps. - Create a color legend that works both in grayscale and color.
- Compare the performance of different palettes in colorβblind simulation.
β Submission Checklist
Before submitting, make sure:
-
Your assignment has fulfilled all the basic requirements listed above.
-
Use Quarto to render the notebook into HTML and zip the files for submission.
-
Double-check the visualizations and your reflections in the HTML are properly organized and displayed.