Issue
this is my table for the question.
I want to get a figure with 3 lines.
(legend : aaa_bbb_L, aaa_bbb_Q, aaa_bbb_ZL)
df = pd.DataFrame({
'A': ['aaa','aaa','aaa','aaa','aaa','aaa','aaa','aaa','aaa','aaa','aaa','aaa'],
'B': ['bbb','bbb','bbb','bbb','bbb','bbb','bbb','bbb','bbb','bbb','bbb','bbb'],
'DC': ['L','L','L','L','Q','Q','Q','Q','ZL','ZL','ZL','ZL'],
'score' : [0.1,0.2,0.3,0.4,0.11,0.21,0.31,0.39,0.1,0.22,0.3,0.42],
'max_sel' : [2.0,3.3,6.0,7.1,3.1,4.0,8.0,8.9,1.2,3.0,5.0,6.6]
})
df.groupby(["A","B","DC"]).plot(legend = True, xlabel='score', ylabel="max_sel",x="score", y = "max_sel")
plt.show()
I tried but the above code made 3 different figure. how to get the figure like this
Solution
Is this what you want?
fig, ax = plt.subplots()
for key, grp in df.groupby(['A','B','DC']):
ax = grp.plot(ax=ax, kind='line', x='score', y='max_sel', label=key, marker='o')
gives you the following result:
Answered By - Noskario
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.