Exercise: Hours of Sunshine

The climate of a place can have a tremendous impact on people’s lived experience, ranging from personal moods to how an entire region defines itself. Here, we’ve collected a set of monthly climate measurements for six major U.S. cities, roughly covering the edges of the continental United States.

In this exercise, your task is to create and then customize a basic visualization plotting the hours of sunshine across the year. You may work in groups of 1-3 people.


Data

The data comes from https://www.usclimatedata.com/, which uses measurements averaged over the years 1981-2010.

The data table consists of the following columns:

The table contains 72 rows, one for each city and month:


Task 1: Visualize Sunshine Hours by City

Your first task is to create a line chart that (as best you can) matches the image below. You must provide visual encodings for three data fields: the city, the month number, and the hours of sunshine.

The source code for this page includes some helpful scaffolding: it loads the dataset, imports a render method to render Vega-Lite JSON specifications, and includes an (incomplete) code block for you to fill in.


Task 2: Further Customize Your Chart

Your next task is to modify and stylize your chart to (again, as best you can) match the image below. First, carefully note the differences between this chart and the previous one and list them below (we’ve included one entry one for you).

Differences between Charts:

Second, fill out the code block in the source code of this document to create a chart matching the image above. Some links you might find helpful include the Vega-Lite encoding field, sort, and axis documentation.


Don’t forget to add, commit, and push your exercises to your GitLab repo!