Percentuale grafico a barre imbottito - Errore = "TypeEerror: solo array di dimensioni -1 possono essere convertiti in scalari di Python" - Perché i valori X & Y non sono riconosciuti? [Chiuso
-
01-11-2019 - |
Domanda
df = pd.DataFrame(raw_data)
raw_data = {'X':[x1,x2,x3], 'Y':[y1,y2,y3]}
r =np.arange(len(df))
totals = [n+m for n,m in zip(df['X'], df['Y'])]
X = [n / m * 100 for n,m in zip(df['X'], totals)]
Y = [n / m * 100 for n,m in zip(df['Y'], totals)]
barWidth = 0.8
names = ("R 1","R 2","R 3")
plt.bar(r, X, color='r', edgecolor='black', width=barWidth,label="X")
plt.bar(r, Y, bottom=X, color='c', edgecolor='black', width=barWidth,label="Y")
plt.title("TEST - Stacked bar graph (%)",y=1.05,fontsize=20)
plt.xticks(r, names)
plt.xlabel("Vrsta obrazovanja",fontsize=15)
plt.ylabel("Precentage %",fontsize=15)
plt.legend(loc="lower center")
plt.show()
Nessuna soluzione corretta
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a datascience.stackexchange