Improper formatting for input to ListPlot3D, backwards incompatibility on 12.1?
You can use BSplineFunction
and ParametricPlot3D
:
bsF = BSplineFunction @
Table[{x[t, x0], t, f[t, x0]}, {x0, -0.5, 3.0, 0.1}, {t, 0, 2, 0.1}];
ParametricPlot3D[bsF[u, v], {u, 0, 1}, {v, 0, 1},
ColorFunction -> "DarkRainbow", PlotStyle -> Directive[Opacity[0.9]],
MeshFunctions -> {#2 &}, Boxed -> False, BoxRatios -> {1, 1, 1/2},
ImageSize -> 600,
AxesLabel -> {Style["<--X-->", Italic, 23],
Style["<--T-->", Italic, 23], Style["U(X,T)", Italic, 23]}]
Similar to kglr's answer but without the use of splines.
Since the plot folds over, there are portions of the plot for which there is not a unique z
for an {x, y}
. ParametricPlot3D
is able to handle such cases.
Clear["Global`*"]
(*Initial condition*)
f0[x_] := Exp[-(2*(x - 1))^2];
x[t_, x0_] := x0 + f0[x0]*t;
f[t_, x0_] := f0[x0];
ParametricPlot3D[{x[t, x0], t, f[t, x0]}, {t, 0, 2}, {x0, -1/2, 3},
ColorFunction -> "DarkRainbow",
PlotStyle -> Opacity[0.9],
MeshFunctions -> {#2 &},
Boxed -> False,
ImageSize -> 600,
AxesLabel -> (Style[#, Italic, 23] & /@ {"<--X-->", "<--T-->", "U(X,T)"}),
PlotRange -> Full]