I can’t figure out how to display the actual years on the x axis. Notice in the image that all years are rounded down to the decade.
Here’s the code that is called in a function:
years = [1955, 1965, 1975, 1985, 1995, 2005, 2015]
# Global Temperatures
# https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/global/time-series
df_temp_anomaly = pd.read_csv('https://raw.githubusercontent.com/rebeccapeltz/emissions/refs/heads/main/global-temp-anomaly-data.csv',skiprows=4)
temp_anomalies = df_temp_anomaly[df_temp_anomaly['Year'].isin(years)]['Anomaly'].tolist()
# Create the bar chart
fig2 = go.Figure(data=[
go.Bar(x=years, y=temp_anomalies, marker_color='black')
])
fig2.update_layout(
title='Global Temperature Anomalies<br><a href="https://raw.githubusercontent.com/rebeccapeltz/emissions/refs/heads/main/global-temp-anomaly-data.csv" target="_blank">data</a>',
xaxis_title='years',
yaxis_title='Temp Anomalies C °',
template='plotly_white'
)
return fig2