I'm doing some graphs but for a data set (Dataset) I need to group multiple columns and generate a graph, I this I'm complicating to much and I don't know how to show in that graph the labels. I've been trying and looking for a solution but I'm stock so I ask for help or advices to do it better or with a diferent aproach, this is my code:
import pandas as pd
import numpy as np
from google.colab import files
from matplotlib import pyplot as plt
df = pd.read_excel('responses.xlsx')
dfq1 = df[[
'Slow songs or fast songs', 'Dance', 'Folk', 'Country',
'Classical music', 'Musical', 'Pop'
]]
a = dfq1['Slow songs or fast songs'].value_counts()
b = dfq1['Dance'].value_counts()
c = dfq1['Folk'].value_counts()
d = dfq1['Country'].value_counts()
e = dfq1['Classical music'].value_counts()
f = dfq1['Musical'].value_counts()
g = dfq1['Pop'].value_counts()
N = 5
ind = np.arange(N)
width = 0.15
avals = [a[1.0],a[2.0],a[3.0],a[4.0],a[5.0]]
bar1 = plt.bar(ind, avals, width, color = 'r')
bvals = [b[1.0],b[2.0],b[3.0],b[4.0],b[5.0]]
bar2 = plt.bar(ind+width, bvals, width, color='g')
cvals = [c[1.0],c[2.0],c[3.0],c[4.0],c[5.0]]
bar3 = plt.bar(ind+width*2, cvals, width, color = 'b')
dvals = [d[1.0],d[2.0],d[3.0],d[4.0],d[5.0]]
bar4 = plt.bar(ind+width*3, dvals, width, color = 'y')
evals = [e[1.0],e[2.0],e[3.0],e[4.0],e[5.0]]
bar5 = plt.bar(ind+width*4, dvals, width, color = 'c')
plt.xlabel("Answers")
plt.ylabel('No. answers')
plt.title("What kind of music do you rate better?")
plt.xticks(ind+width,['1.0', '2.0', '3.0', '4.0', '5.0'])
plt.legend( (bar1, bar2, bar3, bar4), ('Slow songs or fast songs', 'Dance', 'Folk', 'Country', 'Classical music') )
#plt.show()
plt.style.use('seaborn')
plt.figure(figsize=(16, 16))
plt.savefig('/content/q1.png')
this is the graph:
