I give the below MWE
to describe the kind of customization I would like to apply to my figure.
My current df
looks like this:
df = pd.DataFrame(
{'feature': ['abc','bcd','abd','dax','cax','bax','def','deg','abe','cde'],
'score': [0.7732,0.8412,0.8626,0.8705,0.8811,0.8851,0.8884,0.8922,0.8934,0.8949]}
)
df
feature score
0 abc 0.7732
1 bcd 0.8412
2 abd 0.8626
3 dax 0.8705
4 cax 0.8811
5 bax 0.8851
6 def 0.8884
7 deg 0.8922
8 abe 0.8934
9 cde 0.8949
To plot the score
(y-axis) against feature
I proceed like so:
m = df.T
m
0 1 2 3 4 5 6 7 8 9
feature abc bcd abd dax cax bax def deg abe cde
score 0.7732 0.8412 0.8626 0.8705 0.8811 0.8851 0.8884 0.8922 0.8934 0.8949
k_feat = sorted(m.keys())
avg = [m[k]["score"] for k in k_feat]
plt.plot(k_feat, avg, color="blue", marker="o")
To obtain:
As it now, the x-axis is labelled with indices of the feature
. How do I modify this to get x-axis labelled with the corresponding feature name instead (i.e. 0 -> abc, 1 -> bcd, 2 -> abd ....
)?