x = y = np.arange(5)
fig, ax = plt.subplots()
ln, = ax.plot(x, y, lw=10, solid_capstyle='round')
ln2, = ax.plot(x, 4 - y, lw=10)
ln2.set_solid_capstyle('round')
ax.margins(0.2)
How to draw rounded line ends using matplotlib