For a better animation of the solution from NDSolve
To prevent shaking, try to add ImagePadding
and for the other issue, you can fix the vertical plot range.
mpl = Table[
Plot3D[myfun[x, y, t], {x, 0, L}, {y, 0, L},
PlotRange -> {Automatic, Automatic, {0, 6}}, PlotPoints -> 40,
ImageSize -> 400,
PlotLabel -> Style["t = " <> ToString[t], Bold, 18],
ImagePadding -> 30], {t, 0, 27, 1}];
I only post this as a way (without distortion or dealing with multiple scales)to illustrate the initial Gaussian (flat relative to final range) with MeshFunctions
and using ColorFunction
. I have voted for Nasser's answer.
fun[t_] := Legended[Show[
Plot3D[myfun[x, y, t], {x, 0, 20}, {y, 0, 20},
MeshFunctions -> (#3 &), Mesh -> {{0, 1, 1.1, 1.2, 2, 3, 4, 5}},
MeshStyle -> Thick,
ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][z/6]],
ColorFunctionScaling -> False,
PlotRange -> {0, 6},
PlotPoints -> 40,
PerformanceGoal -> "Quality",
PlotLabel -> Style[Row[{"t= ", t}], 20, White, Bold]],
Background -> Black], BarLegend[{"Rainbow", {0, 6}}]]
The gif was exported from fun/@Range[0,27,0.5]
at 8 frames per second (using "DisplayDurations"
.