How to display exact values in a matplotlib pyplot made from a pandas DataFrame?
Question:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'month':['jan','feb'], 'val':[1.3,2.4]})
df.plot(kind='bar', x='month', y='val')
plt.show()
As of now this displays a graph correctly, but how can I get the exact numerical value displayed somewhere above or on each bar? I’ve tried referencing this but it doesn’t seem to work for dataframes.
Answers:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'month':['jan','feb'], 'val':[1.3,2.4]})
df.plot(kind='bar', x='month', y='val')
plt.show()
As of now this displays a graph correctly, but how can I get the exact numerical value displayed somewhere above or on each bar? I’ve tried referencing this but it doesn’t seem to work for dataframes.