add text to pandas dataframe plot

Question:

I am plotting a dataFrame and I want to add information about the information (mean and std of the data)
I am plotting the data this way:

df = pd.DataFrame({'type': lifeExpExcel['Country'], 'Infant mort. rate':
lifeExpExcel['Infant mort. rate']})
ax = df.plot(kind='bar',x= lifeExpExcel['Country'])
ax.set_ylabel('Infant mort. rate')
ax.set_xlabel('Country')
plt.show()

I want to add two string (val + name) to the plot
How can I do this?

btw if there’s a better way to do the plot i’ll like to know that

Asked By: Shai Zarzewski

||

Answers:

You can use ax.text() or ax.annotate()

ax.text accepts the string and then the x-coord and y-coord (in data coordinates) as arguments. ax.annotate is a little more complicated: http://matplotlib.org/1.3.1/users/annotations_intro.html

Answered By: Paul H