Visualize time series data with smoothed line charts
1 of 6

This guide builds on First steps with Observable.

In this guide, we’ll look at how electricity use varied with temperature over the year 2021 in two American cities: Los Angeles, CA and Seattle, WA.

We’ve prepared the data for you and attached it to this notebook in CSV (comma-separated values) files. The power_vs_temperature variable contains the combined data. Click the triangle ▶ next to the word Array to inspect the temperature and electricity use values.

Click on a button on the left and add a Multi-series line chart by entering part of its name and then clicking on it or pressing Enter. Rename the data variable from industries to power_vs_temperature and replace the y and z field names with y: "temperature" and z: "city", respectively.

The Plot.lineY function call should now look like this:

Plot.lineY(power_vs_temperature,
     {x: "date", y: "temperature",
          z: "city"})

Once you run the cell, you’ll see a line chart with one line for each city.