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
Create df using DataFrame with x, y and index keys. Create a figure and a set of subplots using subplots() method. Plot a series of data frame using plot() method, kind='scatter', ax=ax, c='red' and marker='x'.
You can set the labels on that object. Or, more succinctly: ax. set(xlabel="x label", ylabel="y label") . Alternatively, the index x-axis label is automatically set to the Index name, if it has one.
rot : This keyword argument allows to rotate the markings on the x axis for a horizontal plotting and y axis for a vertical plotting. fontsize : Allows to set the font size for the labels and axis points. colormap : This keyword argument allows to choose different colour sets for the plots.
You can use ax.text()
or ax.annotate()
ax.text
accepts the the x-coord and y-coord (in data coordinates) and then the string as arguments. ax.annotate
is a little more complicated: http://matplotlib.org/1.3.1/users/annotations_intro.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With