Iโm attempting to plot several years of average temperatures (by month) in a line graph like so:
in the screenshot, you can notice that the 2012 line is a similar shape to the average, but seems to be missing 11 & 12 (November & December).
Actually, the data is missing January & February like so:
year | month | TMR_SUB_18 |
---|---|---|
2012 | 3 | 23.61949528936744 |
2012 | 4 | 39.28492329149238 |
2012 | 5 | 49.55534946236562 |
2012 | 6 | 60.311488178025115 |
2012 | 7 | 60.60436827956987 |
2012 | 8 | 60.590900537634425 |
2012 | 9 | 50.8024712643678 |
2012 | 10 | 37.558411843876144 |
2012 | 11 | 22.451902777777793 |
2012 | 12 | 10.810748317631226 |
there are several periods of missing data in the dataset (which is growing with time) so manually filling in โfillerโ data is not a preferred option.
ideally, iโd prefer the month of data to match up with the months on the xaxis:
This is how i produce the original graph
fig = go.Figure()
for year in data_test_group.year.unique():
# print(data_test_group.loc[data_test_group.year==year].groupby(['year', 'month'])['TMR_SUB_18'].mean())
fig.add_trace(go.Scatter(x=month_list,
y=data_test_group.loc[data_test_group.year==year].groupby(['year',
'month'])['TMR_SUB_18'].mean(),
mode='lines+markers',
name=str(year) + ' Monthly Averages',
connectgaps=True,
line_shape='spline'))
fig.update_xaxes(nticks=12)
fig.update_xaxes(tick0=1, dtick=1)
fig.add_trace(go.Scatter(x=month_list,
y=data_test_group.groupby(['month'])['TMR_SUB_18'].mean(),
line = dict(color='firebrick',
width=4,
dash='dot'),
name='Average'))
fig.show()
please advise! Thank you in advance!