I'm struggling to create a stacked bar chart derived from value_counts()
of a columns from a dataframe.
Assume a dataframe like the following, where responder
is not important, but would like to stack the count of [1,2,3,4,5]
for all q#
columns.
responder, q1, q2, q3, q4, q5
------------------------------
r1, 5, 3, 2, 4, 1
r2, 3, 5, 1, 4, 2
r3, 2, 1, 3, 4, 5
r4, 1, 4, 5, 3, 2
r5, 1, 2, 5, 3, 4
r6, 2, 3, 4, 5, 1
r7, 4, 3, 2, 1, 5
Look something like, except each bar would be labled by q#
and it would include 5 sections for count of [1,2,3,4,5]
from the data:
Ideally, all bars will be "100%" wide, showing the count as a proportion of the bar. But it's gauranteed that each responder
row will have one entry for each, so the percentage is just a bonus if possible.
Any help would be much appreciated, with a slight preference for matplotlib
solution.