0

i'm trying to figure out how I can get my chart to show the latest (last) Y-axis value in the time series next to the curve line. Currently I have the below graph. I've tried using 'plt.text' but this would mean I manually enter the value rather than python automatically showing me when it generates the chart.

enter image description here

curve_name = 'G_H_TTF-Monthly.USD'
TTF = get_forward_curve_history(name=curve_name, start_date='2018-01-01', 
end_date=date)

NBP_TTF_Q1 = NBP.loc['2020-01-01':'2020-03-31'].mean() - TTF.loc['2020-01- 
01':'2020-03-31'].mean()

NBP_TTF_Q1.plot()


 plt.text(6,40,'0.66')


plt.gca().legend(('NBP_TTF_Q1','Jul19','Jun/Jul18','Jun/Jul19'))
plt.grid()
plt.show()

Whereas I would expect something like this (Excuse the poor pen writing skills):

enter image description here

Asd13
  • 43
  • 8

1 Answers1

0

Try using the last value in your time series data

plt.text(6, 40, NBP_TTF_Q1[-1])

Sam Hollenbach
  • 652
  • 4
  • 19
  • Unfortunately I get the same result as before (basically no change, no text or number is shown next to price curve). – Asd13 Apr 17 '19 at 17:03
  • Actually it works!! Just needed to sort out the aligning for some reason. Thank you so much! – Asd13 Apr 17 '19 at 17:14
  • Actually it works!! Just needed to sort out the aligning for some reason. But currently I have to manually positions where it on the x and y axis. Is there a way I can have it show where the curve ends? plt.text(6, 0.7, NBP_TTF_Q1[-1]), i.e. instead having to input the coordinates could I not just always have it at end of the line? since the chart will update daily. thanks – Asd13 Apr 17 '19 at 17:20