У меня есть данные из двух разных фреймов.
ice_data_dates
Date 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 max_value min_value
Date
01 Jan 12.896 13.353 12.959 13.011 13.073 12.721 12.643 12.484 12.876 13.102 13.353 12.484
02 Jan 12.915 13.421 12.961 13.103 13.125 12.806 12.644 12.600 12.956 13.075 13.421 12.600
03 Jan 12.926 13.379 13.012 13.116 13.112 12.790 12.713 12.634 12.959 13.176 13.379 12.634
04 Jan 13.051 13.414 13.045 13.219 13.051 12.829 12.954 12.724 13.047 13.187 13.414 12.724
05 Jan 13.176 13.417 13.065 13.148 13.115 12.874 12.956 12.834 13.098 13.123 13.417 12.834
ice_data_climo
DOY AverageExtent StdDeviation 10th 25th 50th 75th 90th
0 1 13.778 0.407 13.183 13.479 13.823 14.095 14.257
1 2 13.842 0.434 13.201 13.538 13.886 14.164 14.321
2 3 13.891 0.443 13.264 13.502 13.884 14.283 14.369
3 4 13.930 0.443 13.284 13.590 13.925 14.288 14.417
4 5 13.978 0.437 13.349 13.617 14.036 14.304 14.470
Я делаю линейный график ниже.
fig, ax = plt.subplots()
ice_data_dates.plot(figsize=(20,12), lw=3, fontsize=16, ax=ax, grid=True)
for line in ax.get_lines():
if line._label == '2020':
line.set_linewidth(6)
line.set_color('k')
legend=['2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020', '1981-2010 Average', 'Interquartile Range', 'Interdecile Range']
plt.text(0.80, 0.97, "Sea Ice Extent for" + " " +str(plot_date)+ "=%f $10^6$ km" %ice_today, fontsize=16, horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
plt.text(0.80, 0.94, "Min Sea Ice Extent for" + " " +str(plot_date)+ "=%f $10^6$ km" %min_today, fontsize=16, horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
plt.text(0.80, 0.91, "Max Sea Ice Extent for" + " " +str(plot_date)+ "=%f $10^6$ km" %max_today, fontsize=16, horizontalalignment='center', verticalalignment='center', transform=ax.transAxes)
plt.plot(ice_climo['DOY'], ice_climo['AverageExtent'], c='k', lw=3, linestyle='--')
plt.fill_between(ice_climo['DOY'],ice_climo['AverageExtent'],ice_climo['25th'], color='dimgray', alpha=0.7)
plt.fill_between(ice_climo['DOY'],ice_climo['AverageExtent'],ice_climo['10th'], color='lightgray', alpha=0.5)
plt.fill_between(ice_climo['DOY'],ice_climo['AverageExtent'],ice_climo['75th'], color='dimgray', alpha=0.7)
plt.fill_between(ice_climo['DOY'],ice_climo['AverageExtent'],ice_climo['90th'], color='lightgray', alpha=0.5)
plt.title('Arctic Sea Ice Extent for the Latest 10 Years', fontsize=22, weight='bold' )
ax.set_xlabel("Date", weight='bold', fontsize=16)
ax.set_ylabel("Sea Ice Extent ($10^6$ km)", weight='bold', fontsize=16)
ax.legend(legend, loc='lower left', fontsize=20)
plt.axvline(x=plot_day, c='k', linestyle='--')
Это дает эту цифру.
Но если вы заметили, легенда почему-то перепуталась. Среднее значение за 1981–2010 гг. Должно быть пунктирной черной линией, а средние значения интерквартильных / интердесильных должны иметь разные оттенки серого. Что именно я напортачил с легендой?