Issue
How can I use pyplot to plot this dataframe:
Team Boys Girls
0 Sharks 5 5
1 Lions 3 7
data = {'Team': ['Sharks', 'Lions'], 'Boys': [5, 5], 'Girls': [5, 6] }
df = pd.DataFrame(data)
so that I can end up with something like this where there are two bars per team that denote the boys/girls.
It seems to be a messy process with pyplot, so if there is an easier way I am all ears.
Solution
You can use pandas.DataFrame.plot.bar
with rot=0
to rotate the xticks
df.set_index('Team').plot.bar(rot = 0)
plt.show()
Answered By - Pablo C
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.