Lab 2 Walkthrough: Amounts & Distributions

STAT 80B Week 3 - Thursday

2026-03-10

Welcome to Lab 2!

Today’s Plan

This is a hands-on session:

  1. I’ll demonstrate key techniques
  2. You’ll work on Lab 2 exercises
  3. Ask questions as you go!

Goal: By end of class, you’ll have finished all parts of Lab 2

Lab 2 Overview

Three main parts:

  1. Visualizing Amounts - Create 3 different chart types
  2. Exploring Distributions - Build histograms with different bin widths
  3. Written Reflection - Explain which visualizations work best

Your choice: Tableau, R, or Python (see detailed instructions online)

Getting Started

The Dataset

What we’re working with:

  • We will work with a data set about the age of congress people for this week.
  • Open Tableau, download data from here, and connect with Tableau.
  • Review the list of variables and remember their types

Software Choice

Pick ONE tool for this lab:

Tableau

  • Point-and-click
  • Fast iteration
  • Great for exploration

R

  • ggplot2 package
  • Reproducible code
  • Statistical focus

Python

  • matplotlib/seaborn
  • Integrated analysis
  • General programming

Detailed instructions for each tool are on the lab page!

Part 1: Visualizing Amounts

The Challenge

Create the SAME data visualization using 3 different methods:

  1. Bar chart (your choice: vertical or horizontal)
  2. Dot plot
  3. Heatmap

Why? To see how the same data looks different and learn when each works best.

Method 1: Bar Charts

Basic bar chart steps:

  1. Load your data
  2. Identify the category column (x-axis)
  3. Identify the amount column (y-axis)
  4. Create vertical OR horizontal bars
  5. Add clear labels and title

Bar Chart Tips

Choose vertical bars when:

  • You have 2-8 categories
  • Category names are short (1-2 words)
  • The flow feels natural left-to-right

Choose horizontal bars when:

  • You have 8+ categories
  • Category names are long
  • You want to sort/rank easily

Live Demo: Tableau Bar Chart

Let me show you in Tableau:

  1. Connect to data
  2. Drag category to Rows/Columns
  3. Drag amount to Columns/Rows
  4. Tableau auto-creates bars!
  5. Format and label

Your Turn: Bar Chart (10 min)

Create your first visualization:

  • Open your chosen software
  • Load the dataset
  • Create either vertical OR horizontal bars
  • Add title: “Sales by Category” (or similar)
  • Make sure axes are labeled

Raise your hand if you need help!

Method 2: Dot Plots

What’s different from bars?

  • Show just the endpoint (no full bar)
  • Cleaner, less ink
  • Often easier to read precise values

Same categories, same amounts—different visual!

Live Demo: Creating Dot Plots

In Tableau:

  1. Start like a bar chart
  2. Change mark type from “Bar” to “Circle”
  3. Adjust size of dots if needed

In R: Use geom_point() instead of geom_col()

In Python: Use scatter plot instead of bar plot

Your Turn: Dot Plot (8 min)

Create your second visualization:

  • Same data as before
  • Use dots instead of bars
  • Keep the same orientation (vertical/horizontal)
  • Compare: Does it look clearer or less clear than bars?

Method 3: Heatmaps

A different approach entirely:

  • Categories become rows and columns (2D grid)
  • Amount shown by color intensity
  • No position encoding!

Note: If your dataset is 1D (one category), you might need to create a second grouping or use a simpler color-coded table.

Live Demo: Heatmaps

In Tableau:

  1. Drag first category to Rows
  2. Drag second category to Columns (or create bins)
  3. Drag amount to Color
  4. Choose color palette (sequential works best)

Your Turn: Heatmap (10 min)

Create your third visualization:

  • Arrange data in a grid format
  • Use color to show amounts
  • Choose an appropriate color scale
  • Add a legend/color key

This might be the trickiest one—ask for help if needed!

Part 2: Distributions

The Histogram Challenge

Now we explore distributions:

  • Find a column with many numerical values (not just categories)
  • Create histograms with AT LEAST 3 different bin widths
  • See how the story changes!

This is the most important learning moment of the lab!

What’s a Good Range of Bin Widths?

Try these as a starting point:

  1. Few bins: 5-7 bins (very wide bins)
  2. Medium bins: 15-20 bins
  3. Many bins: 30-50 bins (very narrow bins)

The exact numbers depend on your data range!

Live Demo: Histograms with Different Bins

In Tableau:

  1. Drag numerical column to Columns
  2. Right-click → “Show Missing Values” if needed
  3. Create bins: Right-click field → Create → Bins
  4. Set bin size
  5. Drag bin to Rows, put Count on height

What to Look For

As you change bin width, notice:

  • Does the shape change dramatically?
  • Do you see more/less detail?
  • Where is the center?
  • Are there multiple peaks?
  • Any outliers visible?

Write down what you observe!

Your Turn: Multiple Histograms (15 min)

Create at least 3 histograms:

  1. Wide bins (few bins)
  2. Medium bins
  3. Narrow bins (many bins)

For each, take a screenshot and make notes:

  • What patterns do you see?
  • What’s hidden or revealed?

Part 3: Reflection & Submission

The Writing Component

After creating all visualizations, write 1 paragraph (150-300 words) explaining:

  1. Which visualization of amounts worked best? Why?
  2. How did bin width affect your histogram interpretation?
  3. What would you recommend to someone analyzing similar data?

This shows you’re thinking critically, not just clicking buttons!

What Makes a Good Reflection?

Strong answers include:

  • Specific comparisons (“The dot plot made it easier to see X because…”)
  • Trade-offs (“Bar charts emphasized magnitude, but heatmaps revealed patterns in…”)
  • Evidence from your visualizations (“With 5 bins, the distribution looked smooth, but with 30 bins I could see…”)

Weak answers: “I liked the bar chart because it looks nice.”

Formatting Your Submission

Create ONE PDF containing:

  1. Part 1: Your 3 amount visualizations (bars, dots, heatmap)
  2. Part 2: Your 3+ histograms with different bin widths
  3. Part 3: Your written paragraph

Label each visualization clearly!

Example titles: “Figure 1: Vertical Bar Chart” or “Histogram with 10 bins”

How to Create the PDF

Several options:

  • Screenshot each visualization, paste into Word/Google Docs, export as PDF
  • Use your software’s export function
  • If coding: save plots as images, compile into PDF with markdown

Important: All visualizations must be readable with clear labels!

Grading Criteria

You’ll be evaluated on:

  • Completeness: Did you create all required visualizations?
  • Quality: Are charts labeled and readable?
  • Variety: Did you genuinely try different bin widths?
  • Reflection: Does your paragraph show critical thinking?

Not graded on: Whether you picked the “perfect” visualization (there isn’t one!)

Working Time

The Rest of Class

Use the remaining time to:

  1. Finish creating your visualizations
  2. Experiment with formatting and labels
  3. Start your written reflection
  4. Ask questions!

I’ll circulate to help with technical issues and answer questions.

Common Questions

“Can I use different data?”

  • Stick with the provided dataset for consistency

“Do I need to use all three software tools?”

  • No! Pick ONE and stick with it

“What if my histograms all look similar?”

  • Try more extreme bin widths (very few or very many)

Tips & Troubleshooting

Tableau-Specific Tips

Common issues:

  • Data not loading? Check file format (CSV works best)
  • Bars not showing? Make sure you dragged to correct shelf
  • Colors weird? Change the color palette in Marks card
  • Can’t find bins? Right-click on measure → Create → Bins

R-Specific Tips

Key functions:

# Bar chart
ggplot(data, aes(x = category, y = amount)) + geom_col()

# Dot plot
ggplot(data, aes(x = category, y = amount)) + geom_point()

# Histogram
ggplot(data, aes(x = values)) + geom_histogram(bins = 10)

Change bins = 10 to try different widths!

Python-Specific Tips

Key functions:

# Bar chart
plt.bar(categories, amounts)

# Dot plot
plt.scatter(categories, amounts)

# Histogram
plt.hist(values, bins=10)

Seaborn makes things prettier:

sns.histplot(data=df, x='column', bins=10)

Getting Help

If you’re stuck:

  1. Check the detailed lab instructions (has step-by-step for each tool)
  2. Ask a classmate
  3. Raise your hand—I’m here to help!
  4. Office hours: Check syllabus

Remember: Struggling is part of learning!

Closing

What You Should Accomplish Today

Minimum goals:

  • At least 2/3 amount visualizations started
  • At least 2/3 histograms created
  • Understanding of how to complete the rest

Ideal goals:

  • All visualizations complete
  • Reflection paragraph drafted
  • Ready to submit!

Due Date Reminder

Lab 2 is due: today

  • Submit via Canvas
  • One PDF file
  • Name your file: LastName_FirstName_Lab2.pdf

Late policy: See syllabus

Final Thoughts

What you’re learning:

  • Technical skills (software tools)
  • Design thinking (which chart to use)
  • Critical analysis (how choices change meaning)

This is the foundation for all future labs!

Questions?

Use the remaining class time to work on Lab 2.

I’ll be walking around to help!