11

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

1 Answer 1

12

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.