The most of contents borrowed from the book 『Python Data Science Handbook: Essential Tools for Working with Data, Jake VanderPlas, O'REILLY, 2017』. I have just added somewhat object-oriented or matlab style codes.
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
x = np.linspace(0, 10, 1000)
# 1. inside plot()
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.plot(x, np.sin(x), '-g', label='sin(X)')
ax1.plot(x, np.cos(x), ':b', label='cos(X)')
ax1.axis('equal')
ax1.legend()
#ax1.legend('sin(x), cos(x)')
# 2. using line ojbects
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
line1, = ax1.plot(x, np.sin(x), '-g')
line2, = ax1.plot(x, np.cos(x), ':b')
ax1.axis('equal')
line1.set_label('sin(x)')
line2.set_label('cos(x)')
ax1.legend()
# 3. using legend()
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
line1, = ax1.plot(x, np.sin(x), '-g')
line2, = ax1.plot(x, np.cos(x), ':b')
ax1.axis('equal')
#legend(handles, labels)
ax1.legend((line1, line2), ('sin(X)', 'cos(X)'))