Use dataframe column names as labels in pylab.plot
I think it's the way you have your data set up in part of the code you're not showing.
Here's an example, I used df.plot()
in this case.
import pandas as pdimport randomimport matplotlib.pyplot as pltx = [random.randint(10,20) for r in range(100)]y = [random.randint(0,10) for r in range(100)]df = pd.DataFrame([x,y]).T #T for transposedf.columns=['a','b']df.plot(kind='line')plt.legend(loc='upper left')plt.show()
Edit
pylab
version
import pandas as pdimport randomimport matplotlib.pylab as pltx = [random.randint(10,20) for r in range(100)]y = [random.randint(0,10) for r in range(100)]df = pd.DataFrame([x,y]).Tplt.plot(df)plt.legend(['a','b'],loc='upper left')plt.show()