I\'m drawing a graph with some lines using matplotlib and I want to display the final y
value next to where each line ends on the right hand side like this:
Very useful Joe. Only one more detail. If the final value isn't a maximun, you can use y[-1]. I added a horizontal line to clarify.
gbm = np.log(np.cumsum(np.random.randn(10000))+10000)
plt.plot(gbm)
plt.annotate('%0.2f' % gbm[-1], xy=(1, gbm[-1]), xytext=(8, 0),
xycoords=('axes fraction', 'data'), textcoords='offset points')
plt.axhline(y=gbm[-1], color='y', linestyle='-.')
plt.show()
Plot with final y-axis value marked.