I working with matplotlib and below you can see my data and my line plot.
data = {
'Year': ["2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020","2021"],
'Sales':[8.7,5.7,5.8,5.6,5.5,5.3,5,4.8,4.2,4.2,4.1,4.1,4.1,4.1,4.7,4.6,4.8,4.9,5.3,5.4,5.7,5.7],
}
df = pd.DataFrame(data, columns = ['Year',
'Sales',
])
df.plot(x='Year', kind='line', stacked=True,legend=None,xlabel='',ylabel='In percentage (%)')
Now I want to add specific annotation on the line of this plot in year 2000, 2010 and 2020.
Annotation text are: For 2000 "GST 10 %, 15 and 20%"
for 2010 "GST 10 %, 18 and 25%"
and for 2020 "GST 15 %, 19 and 21%"
. Below you can see how need to look.
So can anybody help me how to solve this problem?
CodePudding user response:
Any specific reason you inputted the year as a string? Anyway, I converted it to a number for convenience. To annotate, you can use