Reputation: 4444
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) :
How would I get this :
Upvotes: 0
Views: 687
Reputation: 43
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()
Upvotes: 0
Reputation: 262294
You could use annotate
:
import numpy as np
x = np.linspace(0,6.5)
y = np.sin(x)
plt.plot(x,y,label='blabla')
plt.plot(x[-1], y[-1], marker='+')
plt.annotate(f'({x[-1]:.2f}, {y[-1]:.2f})', (x[-1], y[-1]), ha='right')
output:
Upvotes: 1