I was checking the following example of matplotlib and came across something that I feel is weird.
import matplotlib.pyplot as plt
line1, = plt.plot([1,2,3], label="Line 1", linestyle='--')
line2, = plt.plot([3,2,1], label="Line 2", linewidth=4)
line3, = plt.plot([4,5,6], label='Line 3')
line4, = plt.plot([-4,-5,-6], label='Line 4')
# Create a legend for the first line.
first_legend = plt.legend(handles=[line1, line3], loc=1)
# Add the legend manually to the current Axes.
ax = plt.gca().add_artist(first_legend)
# Create another legend for the second line.
plt.legend(handles=[line2, line4], loc=4)
plt.show()
Why do we need to add a trailing comma to line in order for it to work?