update: i tried the following, now the colors match but the legend adds some unused lines
n = 101;
x = linspace(-100, 100, n);
y = linspace(-100, 100, n);
[X, Y] = meshgrid(x, y);
clr = ['r','g','b','c','k'];
a = 4;
e = [-50 -10 0 50];
t = linspace(-50, 50, 5);
LegendsStrings = cell(numel(t),1);
for q = 1:a
for r = 1:5
Z = fn(X, Y, e(q), t(r), n);
subplot(2, 2, q)
xline(0, 'Color', 'k', 'LineWidth', 0.5);
yline(0, 'Color', 'k', 'LineWidth', 0.5);
hold on
LegendsStrings{r} = ['t = ', num2str(t(r))];
v = [0, 0];
contour(X, Y, Z, v, 'LineWidth', 1.5, 'LineColor', clr(r), 'DisplayName', LegendsStrings{r})
xlabel('x')
ylabel('y')
title("e = " + e(q))
grid on
axis equal
hold off
% xp = [-95, -80];
% yp = (-30-12*r)*ones(1, 2);
% plot(xp, yp, ['-', clr(r)])
% text(xp(2)+5, yp(2),['t = ', num2str(t(r))],'FontSize',8)
end
legend()
end