# How to plot a line from a surface

I have a surface difference that I have defined as an expression of x and t and can plot it, but I'm running into some trouble when I try to plot a 2d slice of the plot by itself on the line x = 0.25. I have tried to plot the 2d surface by defining a new function diff2d where I use With to set the value of x to 0.25, but this is not giving me any output for the plot.

What is a way to plot this line that I'm missing?

neq = 40;
sea[n_] := 2*Integrate[-Sin[n*Pi*x], {x, 0, 1}]
vn = Table[0, {n, 1, neq}];
Do[{vn[[n]] = sea[n] Sin[n*Pi*x] Exp[-(n*Pi)^2 * t]}, {n, 1, neq}]
vn;
v = Total[vn];
u = v + 1;
difference = u - Erfc[x/Sqrt[4 t]];
diff2d = With[{x = 0.25}, u - Erfc[x/Sqrt[4 t]]];
Plot3D[u, {x, 0, 1}, {t, 0, 1}, AxesLabel -> {"x", "t", "u"}]
Plot3D[Erfc[x/Sqrt[4 t]], {x, 0, 1}, {t, 0, 1},
AxesLabel -> {"x", "t", "Erfc"}]
Plot3D[Evaluate[difference], {x, 0, 0.5}, {t, 0, 1},
AxesLabel -> {"x", "t", "Difference"}]
Plot[Evaluate[diff2d], {t, 0, 1},
AxesLabel -> {"t", "Difference on x = 0.25"}]

• MeshFunctions->(#1&),Mesh->{{0.25}} Apr 8 at 2:10

I found a hacky workaround, by using With[{x = 0.25}, Evaluate[diff2d]. I ran this part and copied the output of this new line into a plot statement. It has obvious disadvantages, like being wrong if I ever redefine my function without copying and pasting again, but works in a pinch.