Reputation: 1062
The picture shows some graphs plotted on top of each other. The thin ones have 4 data points using the style:
plot(xdata,ydata),'|-',lw=1.5,markersize=10)
and the thick, shorter ones spanning only a subset of the data points using:
plot(xdata[-2:-1],ydata[-2:-1],'-',lw=4.5)
The thick lines are however overshooting at their ends. How can I make them end right at the data points and coincide with the markers?
Upvotes: 3
Views: 340
Reputation: 6699
I think this is because the default cap style on lines is "projecting", while you need it to be "butt". If so, something like this should help:
overlapped = plot(xdata[-2:-1],ydata[-2:-1],'-',lw=4.5)
for item in overlapped:
item.set_solid_capstyle('butt')
Upvotes: 4