I have multiple data frames in this format:
year count cum_sum
2001 5 5
2002 15 20
2003 14 34
2004 21 55
2005 44 99
2006 37 136
2007 55 191
2008 69 260
2009 133 393
2010 94 487
2011 133 620
2012 141 761
2013 206 967
2014 243 1210
2015 336 1546
2016 278 1824
2017 285 2109
2018 178 2287
I have generated a plot as the followig: enter image description here
The following code has been utilized for this purpose:
fig, ax = plt.subplots(figsize=(12,8))
sns.pointplot(x="year", y="cum_sum", data=china_papers_by_year_sorted, color='red')
sns.pointplot(x="year", y="cum_sum", data=usa_papers_by_year_sorted, color='blue')
sns.pointplot(x="year", y="cum_sum", data=korea_papers_by_year_sorted, color='lightblue')
sns.pointplot(x="year", y="cum_sum", data=japan_papers_by_year_sorted, color='yellow')
sns.pointplot(x="year", y="cum_sum", data=brazil_papers_by_year_sorted, color='green')
ax.set_ylim([0,2000])
ax.set_ylabel("Cumulative frequency")
fig.text(x = 0.91, y = 0.76, s = "China", color = "red", weight = "bold") #Here I have had to indicate manually x and y coordinates
fig.text(x = 0.91, y = 0.72, s = "South Korea", color = "lightblue", weight = "bold") #Here I have had to indicate manually x and y coordinates
plt.show()
The problem is that the method for adding text to the plot is not recognizing the data coordinates. So, I have had to manually indicate the coordinates of the labels of each dataframe (please see "China" and "Korea"). Is there a clever way of doing it? I have seen an example using ".last_valid_index()" method. However, since the data coordinates are not being recognized, it is not working.