How can I get a result ... where the lines connect to the endpoints of the markers?
Introduce new datapoints, corresponding to the endpoints of markers. Ask matplotlib to alternately plot dotted lines, then solid lines for markers, then dotted lines....