To make the bottom gray line, you can also change the drawing order.
t = linspace(0, 10, 1000); y1 = 2*t; y2 = 3*t; figure; h3 = plot([5, 5], [0, max(y1)], 'LineWidth', 6, 'Color', [0.6, 0.6, 0.6]); hold on; [ax, h1, h2] = plotyy(t, y1, t, y2); set(h1, 'LineWidth', 4); set(h2, 'LineWidth', 4);
There is a trick in h3 = plot(...) to make sure that the left scale is correct.

source share