Is there any way I could use the MaxStepFraction
(or grid size) as used in NDSolve
in the example below as ticks on the 3d Plot?
That was I would be able to plot the grid points on the X and Y axis.
I tried creating a table and using that as the argument in Ticks
but that didn't work.
Minimum working example:
Clear[u, L, t, x, y, sol, Eq]
L = 4;
Eq = -D[u[t, x, y], t, t] + D[u[t, x, y], x, x] +
D[u[t, x, y], y, y] + Sin[u[t, x, y]];
uSol = u /. NDSolve[{
Eq == 0, u[t, -L, y] == u[t, L, y],
u[t, x, -L] == u[t, x, L],
u[0, x, y] == Exp[-(x^2 + y^2)],
Derivative[1, 0, 0][u][0, x, y] == 0
},
u,
{t, 0, L/2}, {x, -L, L}, {y, -L, L},
MaxStepFraction -> 1/11
][[1]]
tt = 1.2;
Plot3D[ uSol[tt, x, y], {x, 0, L}, {y, 0, L},
Ticks -> {{0, 2/5, 4/5, 6/5, 8/5, 2, 12/5, 14/5, 16/5, 18/5, 4}, {0,
2/5, 4/5, 6/5, 8/5, 2, 12/5, 14/5, 16/5, 18/5, 4}}]
The ticks in the above figure were created using, Table[i 4/10, {i, 10}]
and then manually pasted into the curly brackets. Obviously, that isn't the most efficient way.
I tried pasting the Table
command inside Plot3D
but that didn't work.
Ticks -> Evaluate[{Table[(* stuff *)], (* other ticks *)}]
;Plot3D[]
isHoldAll
, see... $\endgroup$Evaluate
.... hmm... I never thought of that. This isn't the first time I've come across thisEvaluate
... $\endgroup$HoldAll
attribute of plotting functions isn't really obvious at first glance. $\endgroup$Table
didn't work? For me something likePlot3D[uSol[tt, x, y], {x, 0, L}, {y,0, L}, Ticks -> Table[x, {3}, {x, 0, 4, 1/3}]]
does work, even with theHoldAll
attribute ofPlot3D
. $\endgroup$