Practical GenAI · Part 2

Build research code
you can explain.

Repair a Python or R plot in VS Code with GitHub Copilot. Ask about the code, review a plan, and inspect every change before saving it in Git.

A Fritsche Lab teaching guide · University of Michigan

Two language pathsChoose Python or R for the same plotting exercise.
Work in VS CodeUse Copilot Chat to run code and Explorer to open plots.
See what changedReview changed files and color-coded diffs in Source Control.

Practising what we teach: this guide and exercise were developed with substantial AI assistance in writing, coding, testing, and review. They are provided as is, without warranty, to the extent permitted by applicable law. Review the code, agent instructions, permissions, and results before use. Read the AI-assistance disclosure, use guidance, and warranty notice.

Pick up where Part 1 leaves off

Part 1 introduced planning, prompting, and reviewing code. Here you put those habits to work on a plot with overlapping bars and clipped labels.

Choose Python or R, complete the VS Code + Copilot setup, and follow six lessons online or offline. Clone the example through Source Control, repair the plot without changing its values, and leave a result a labmate can rerun. You can complete the main path without typing shell commands.

Prefer Claude Code? Its VS Code extension supports the same exercise and visual Git review. Command-line users have a complete CLI appendix.

Keep your judgment and coding skills. Working output can hide code you cannot explain or maintain. Review permissions, keep changes proportional to the task, and practise without AI so your work can continue if access becomes unavailable or prohibited. Read permissions and independent work.

Grouped bars compare invented measurement-completeness counts for Groups A and B. Group B has more complete measurements, 64 versus 42; the linked specification lists all category values.

Your target: a readable chart for the fictional Journal of Unnecessarily Specific Figures (JUSF). The exercise shows the problem; its local figure specifications give the rules.

Make accessibility part of every figure: readable labels, sufficient contrast, groups identifiable without color, and reviewed alternative text.

If you are new to using GenAI for coding, begin with Part 1. If you already work in Python or R, start here; the lessons explain the agent controls and Git review.

A practical learning path

From the first run to a reviewed change

Keep the project small so you can see the whole workflow.

  1. Establish a working baseline

    Set up VS Code, ask Copilot to run the existing checks, and open the baseline plot in Explorer.

    Open the quickstart
  2. Make the repository understandable

    Use a README, agent instructions, a repository map, and data contracts to make expectations explicit.

    Explore repository practices
  3. Choose one small improvement

    Use Ask to understand, Plan to agree on the repair, and Agent to implement and check it.

    Work through the lessons
  4. Leave a useful result

    Compare the plots, review each diff in Source Control, and commit the source with a useful handoff.

    Learn visual Git review

Make it useful in your own work

Choose what you need next

Set up VS Code + Copilot

Install the tools, sign in, clone the exercise, and make the first plot.

Detailed setup

Reuse the templates

Write a task brief, agree on the data, or hand off unfinished work.

Browse templates

Teach a lab session

Use the 45-minute runbook and a focused live exercise.

Teaching materials