'Python - MatplotLib - Annotate Last Point

Wondering How to add Marker + Corresponding value to the last point of a series.

To plot my series I use :

var= pd.read_excel("ExcelFilePath")
x = list(var['Date'])
y = list(var['Values'])
plt.plot(x,y,label='blabla')

Which Give (For example) :

enter image description here

How would I get this :

enter image description here



Solution 1:[1]

You could use the Plotly Library for this.

e.g.

import plotly.express as px
df = px.data.gapminder().query("continent == 'Oceania'")
fig = px.line(df, x='year', y='lifeExp', color='country', markers=True)
fig.show()

This will give you an output: plotly marker example

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1