x = linspace(0, 4 * pi, 10000)
y = cos(x)
lwidths = 1 + x[:-1]
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
lc = LineCollection(segments, linewidths=lwidths, color='blue')
fig, a = plt.subplots()
a.add_collection(lc)
a.set_xlim(0, 4 * pi)
a.set_ylim(-1.1, 1.1)
fig.show()
График Matplotlib с переменной шириной линии