以下のnumpy配列を
Python
1array([[1.28876595e-02, 3.11055846e-05, 3.25031914e-02, 8.63876939e-01, 2 3.08285896e-02, 4.37524468e-02, 1.61199812e-02]], dtype=float32)
次のようなx軸のラベルをつけて棒グラフとして表したいです。
Python
1dict_values(['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral'])
pred_test_labelsにnumpy配列が格納されていて、以下のようなコードではとエラーが起こります。
Python
1import matplotlib.pyplot as plt 2 3x = [1,2,3,4,5,6,7] 4y = pred_test_labels 5 6plt.figure(figsize = (10, 6)) 7plt.bar(x, y, align='center', width = 0.5) 8plt.xticks(x,['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral']) 9 10plt.grid(True)

回答1件
あなたの回答
tips
プレビュー