I need to create a legend for a line segment that has a different marker at the bottom and the top of the line. I am able to create a legend with 1 of the marker symbols repeated but not the two different markers on each end.
Here is a reproducible example.
from matplotlib import pyplot as plt
import numpy as np
#Create some data
x = np.arange(0,11)
y1 = np.sqrt(x/2.)
y2 = x
plt.figure(figsize=(8,8))
ax = plt.subplot(111)
#Plot the lines
for i,x_ in zip(range(11),x):
ax.plot([x_,x_],[y1[i],y2[i]],c='k')
#Plot the end points
ax.scatter(x,y1,marker='s',c='r',s=100,zorder=10)
ax.scatter(x,y2,marker='o',c='r',s=100,zorder=10)
ax.plot([],[],c='k',marker='o',mfc='r',label='Test Range') #Create a single line for the label
ax.legend(loc=2,numpoints=2,prop={'size':16}) # How can I add a label with different symbols the line segments?
plt.show()
The end product should have a legend with a symbol showing a line connecting a circle and a square.

