x = np.linspace(0, 10, 100)
y1 = 2 * x
y2 = 3 * x
xthresh = 4.5
diff = np.abs(y1 - y2)
below = diff < xthresh
above = diff >= xthresh
plt.plot(x[below], y1[below], 'b--')
plt.plot(x[below], y2[below], 'g--')
plt.plot(x[above], y1[above], 'b-')
plt.plot(x[above], y2[above], 'g-')
plt.show()
Изменить стиль линии matplotlib в середине графика