Я хотел бы получить оси (x, y) от пика графика (заключительной части графика), чтобы показать последнюю сумму, которую я получил от прогноза COVID в моей стране.
Код:
date_pred = start_date + datetime.timedelta(days=days_future)
start_date_str = start_date.strftime('%d %b, %Y')
date_pred_str = date_pred.strftime('%d %b, %Y')
plt.figure(figsize = (10, 6))
plt.plot(adjusted_dates, y)
plt.plot(future_forecast_days, svm_prediction, linestyle='dashed', color='red')
plt.title('CODVID-19 30 days prediction', size = 20)
plt.xlabel('30 days prediction', size = 13)
plt.ylabel('Cases', size = 13)
plt.legend([f'Confirmed cases | Growth rate: {round(growth_rate)}%', f'SVM predictions | MAX: {int(round(svm_prediction[-1]))}'])
plt.figtext(x = 0.14, y = 0.72, s = f'from: {start_date_str} \nto: {date_pred_str}')
plt.figtext(x = 0.78, y = 0.83, s = f'{int(round(svm_prediction[-1]))} -->')
plt.figtext(x = 0.45, y = 0.25, s = f'{int(np.array(df.Confirmed)[-1])} -->')
plt.xticks(size=10)
plt.yticks(size=10)
plt.show()
Ожидаемый результат:
Идея состоит в замене x, y на plt.figtext
из фактического графика или графика прогноза (здесь я показываю только значение прогноза):
plt.figtext(x = x_pred_final, y = y_pred_final, s = f'{int(round(svm_prediction[-1]))} -->')
plt.figtext(x = x_actual_final, y = y_actual_final, s = f'{int(np.array(df.Confirmed)[-1])} -->')
![enter image description here](https://i.stack.imgur.com/pYSXh.png)