join the Figure Friday session on December 13, at noon Eastern Time, to showcase your creation and receive feedback from the community.
In this week’s Figure-Friday we’ll look at the hourly demand for electricity in New England, US, provided by the US Energy Information Administration (EIA).
In case you’re interested in additional data sets for the New England regions or would like to explore the other graphs made by the EIA, visit their wholesale markets page.
Things to consider:
- can you improve the sample figure below (filled area plot)?
- would a different figure tell the data story better?
- can you create a Dash app instead?
Sample figure:
Code for sample figure:
import plotly.graph_objects as go
import pandas as pd
data = pd.read_csv("https://raw.githubusercontent.com/plotly/Figure-Friday/refs/heads/main/2024/week-49/megawatt_demand_2024.csv")
# Convert the "Local Timestamp" column to a datetime format and filter for October data
data['Local Timestamp'] = pd.to_datetime(data['Local Timestamp Eastern Time (Interval Beginning)'])
october_data = data[(data['Local Timestamp'] >= '2024-10-01') & (data['Local Timestamp'] < '2024-11-01')]
# Prepare the regional data for plotting
regions = [
"Connecticut Actual Load (MW)", "Maine Actual Load (MW)",
"New Hampshire Actual Load (MW)", "Northeast Massachusetts Actual Load (MW)",
"Rhode Island Actual Load (MW)", "Southeast Massachusetts Actual Load (MW)",
"Vermont Actual Load (MW)", "Western/Central Massachusetts Actual Load (MW)"
]
# Create a filled area plot
fig = go.Figure()
for region in regions:
fig.add_trace(go.Scatter(
x=october_data['Local Timestamp'],
y=october_data[region],
mode='lines',
stackgroup='one', # https://plotly.com/python/reference/scatter/#scatter-stackgroup
name=region.split(' ')[0] # Use the first word of the region name as a label
))
fig.update_layout(
title="Hourly Actual Demand for Electricity by Region in October",
yaxis_title="Megawatts (MWh)",
legend_title="Regions",
template="plotly_white"
)
fig.show()
Participation Instructions:
- Create - use the weekly data set to build your own Plotly visualization or Dash app. Or, enhance the sample figure provided in this post, using Plotly or Dash.
- Submit - post your creation to LinkedIn or Twitter with the hashtags
#FigureFriday
and#plotly
by midnight Thursday, your time zone. Please also submit your visualization as a new post in this thread. - Celebrate - join the Figure Friday sessions to showcase your creation and receive feedback from the community.
If you prefer to collaborate with others on Discord, join the Plotly Discord channel.
Data Source:
Thank you to the US Energy Information Administration for the data.