Week 2: Visualizing Reality

Turning Motion Data into Physics Graphs

Pre-service Physics Teacher Training

Today's Objective

  1. Data Structures: Understanding "Lists" as sequences of time and position.
  2. Visualization Literacy: Deciphering the matplotlib library.
  3. The "Architect's Edit": Modifying visual parameters to improve pedagogy.
  4. Verification: Ensuring the AI-generated graph accurately represents the physics.

1. How Computers "See" Motion Data

Introducing the "List" [ ]

In Physics, we record a table of values. In Python, we use a List.

# A list of time measurements (seconds)
time = [0, 1, 2, 3, 4, 5]

# A list of position measurements (meters)
position = [0, 2, 4, 6, 8, 10]
  • The Rule: Both lists must be the same length.

  • The Relationship: The 3rd item in time matches the 3rd item in position.

2. Deconstructing the "Graphing Factory"

The Anatomy of matplotlib

import matplotlib.pyplot as plt  # Load the library

plt.plot(time, position, color='red', marker='o') # Create the line
plt.title("Position vs. Time Graph")              # Add title
plt.xlabel("Time (s)")                            # Label X-axis
plt.ylabel("Position (m)")                        # Label Y-axis
plt.grid(True)                                    # Add a grid
plt.show()                                        # Display it

3. Lab Task 1: The "Architect's Edit" 🛠️

Copy the code from the previous slide into Google Colab and try these edits:

  1. Change the Marker: Change marker='o' to marker='x'.

  2. Change the Color: Change 'red' to 'blue' or 'green'.

  3. Fix the Units: Change the Y-label from "Position (m)" to "Displacement (cm)".

  4. Add more data: Add 6 to the time list and 12 to the position list. What happens if you only add it to one list?

4. Using AI to Model Acceleration 🤖

Prompting for a Curve ()

Prompt Template:

"Write a Python script using matplotlib to plot a position-time graph for an object starting from rest with a constant acceleration of .

  1. Calculate position for to seconds.
  2. Plot the graph with a curve.
  3. Label the axes with correct physics units."

5. Lab Task 2: Validation Challenge

Does the Math match the Picture?

  1. Paste the AI's code into a new cell.

  2. Identify the Physics: Find where the AI defined acceleration ().

  3. The "Moon Test": Change to . Does the graph flatten out as gravity weakens?

  4. Pedagogical Question: How would you explain the difference between a straight line (Week 1) and this curve (Week 2) to a 10th-grade student using this code?

6. Common Visualization Errors 🛑

  • "The Library is Missing": If you forget import matplotlib.pyplot as plt, the computer won't know how to draw.

  • "Dimensional Mismatch": Having 5 time points but 6 position points.

  • "String vs. Number": Putting quotes around your data: [ "0", "1", "2" ]. This makes them labels, not numbers you can calculate.

Homework: The Graph Challenge

Task: Create a Google Colab notebook that plots Velocity vs. Time for a falling object.

  1. Constants: Define .

  2. Formula: .

  3. The Plot: Make the line Green, add a Grid, and ensure the labels include (m/s) and (s).

  4. Share: Submit your link!

Next Week: The "For Loop"

Simulating motion step-by-step.

We will move from plotting "perfect formulas" to simulating "Real Physics" where forces change every second!

"Last week, we looked at Python as a high-powered calculator. Today, we’re moving from 'the answer' to 'the story.' In physics, a graph tells the story of motion. We are going to learn how to tell that story using a library called Matplotlib."

Think of a ticker-tape timer or a motion sensor. It doesn't give you one number; it gives you a sequence. In Python, we store that sequence in a 'List,' which is just a set of brackets. Notice that the time list and the position list are like two sides of a data table. If you have 5 seconds of data, you must have 5 position measurements. If they don't match, the 'system' crashes because the computer doesn't know where to plot that extra point.

Look at the first line: `import matplotlib.pyplot as plt`. Think of this as opening your lab drawer and taking out the graphing paper and ruler. We give it the nickname `plt` to save time. Notice the commands below it: `plt.title`, `plt.xlabel`. These aren't for the computer—they are for the **human reader**. As teachers, this is where we ensure our students are using proper units like 'meters' or 'seconds'."

"Now, I want you to get your hands dirty. Go to your Colab notebook and run the starter code. Once you see the graph, I want you to change the `marker` from a circle to an 'x'. Why? Because in a real lab, data points are often discrete 'marks' rather than a smooth connected line. This is a pedagogical choice you make as a teacher."

"We’re going to ask the AI to write a script for constant acceleration. But remember: you are the **Architect**. The AI might give you the code, but it doesn't know if the graph _looks_ right for a physics classroom. You need to check if it used $1/2 \cdot a \cdot t^2$ or if it hallucinated a different formula. Use the prompt on the screen and see what it builds for you."

"This is the most important part of today. Once you have your acceleration graph, change the gravity variable to $1.6$. In a textbook, a student just sees a different number. In Python, the student sees the entire curve flatten in real-time. This 'visual feedback' is what helps students develop an intuitive sense of how gravity affects motion."

"When your students try this, they will hit errors. The most common one is the 'Dimensional Mismatch.' It's the computer's way of saying 'I have a time for this dot, but no position.' Remind them to count their data points. Also, watch out for 'Quotes.' If you put quotes around a number, Python thinks it's a word and refuses to graph it."