I wrote a 1D solver for the heat equation $u_t=u_{xx}$, and I can animate the solution using normal ListPlot
command, where the x-axis is the rod length, and the y-axis is $u(x,t)$. So for each time instance, I make a new 2D plot, etc...
Another way to view this, is by 3D, where now each frame is a 2D plot at some time instance, and time travels down the page. This gives a nicer view of the diffusion of heat, I think.
So, basically I have a number of 2D frames, and I want to display them in 3D, one frame after the other as time advances.
Using MATLAB I use the mesh
command with holdon
, and here is a screen shot just to show what I mean from a school project I did:
So time advances down the page as the simulation runs.
I wrote the same thing using Mathematica for a demo, here is what I have to far, I got the general layout working using ListPointPlot3D
, but I am not able to figure out how to tell Mathematica to make a curve on top of the points being displayed so I can get the same effect as above.
Here is an example, where here I make a sine wave (this will be my solution from above), and plot the frames in time using Animate
:
f = 0.2;(*hz*)
data1[t_] := Table[Sin[2 Pi f t x], {x, -Pi, Pi, .1}];
data = Table[data1[t], {t, 0, 2, .2}];
Animate[ListPointPlot3D[data[[1 ;; i]], Filling -> Axis,
PlotStyle -> Red, PlotRange -> {Full, {1, Length[data]}, Automatic},
AxesLabel -> {x, "time", "u(x,t)"}], {i, 1, Length[data], 1}]
I kept the Filling -> Axis
in the above just to make it easier to see. I'd like just have curve lines on top of those red points you see there. If I remove the Filling
option, then only the points remain, making it hard to see. Also, I can't use Joined -> True
here.
I tried the ListPlot3D
command also:
f = 0.4;(*hz*)
data1[t_] := Table[Sin[2 Pi f t x], {x, -Pi, Pi, .1}];
data = Table[data1[t], {t, 0, 2, .1}];
Animate[ListPlot3D[data[[1 ;; i]], PlotStyle -> Red,
PlotRange -> {Full, {1, Length[data]}, Automatic},
AxesLabel -> {x, "time", "u(x,t)"}, PerformanceGoal -> "Quality",
Mesh -> 10], {i, 1, Length[data], 1}]
But I need to work more on this, and I find the ListPointPlot3D
clearer if I can get the curves part to work and I think it is more light weight for a demo as I do not want to slow it down too much.
Here is another example from a paper I am reading of the type of plots I'd like to generate of the same PDE solution I have but plots are shown in 3D with time moving down the page:
Question: Any other suggestions to do what I want using Mathematica that I might have overlooked? How can I get the ListPlotPoint3D
to show just curves on top of the points (i.e. joined at the top, like I showed in my MATLAB screen shot). I looked at the Mathematica visualization functions, but did not see something obvious to use so far other than the above.