The following solutions work for me. The first places both lines in one legend, the second splits lines into two legends, similar to what you are trying above.
Here is my dataframe
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list('ABCD'))
One legend solution, credit to this StackOverflow post
plt.figure(figsize=(12,5))
plt.xlabel('Number of requests every 10 minutes')
ax1 = df.A.plot(color='blue', grid=True, label='Count')
ax2 = df.B.plot(color='red', grid=True, secondary_y=True, label='Sum')
h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()
plt.legend(h1+h2, l1+l2, loc=2)
plt.show()
Split legend solution
plt.figure(figsize=(12,5))
plt.xlabel('Number of requests every 10 minutes')
ax1 = df.A.plot(color='blue', grid=True, label='Count')
ax2 = df.B.plot(color='red', grid=True, secondary_y=True, label='Sum')
ax1.legend(loc=1)
ax2.legend(loc=2)
plt.show()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…