# Using MaxStepFraction as ticks on plot

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.

-
Try Ticks -> Evaluate[{Table[(* stuff *)], (* other ticks *)}]; Plot3D[] is HoldAll, see... – J. M. Sep 25 '12 at 13:45
@J.M. Evaluate.... hmm... I never thought of that. This isn't the first time I've come across this Evaluate... – drN Sep 25 '12 at 13:49
@J.M. Are my questions really poor? I thought I'd ask. – drN Sep 25 '12 at 13:49
Well, they aren't poor per se... I suppose the HoldAll attribute of plotting functions isn't really obvious at first glance. – J. M. Sep 25 '12 at 14:00
@drN Can you point out, why Table didn't work? For me something like Plot3D[uSol[tt, x, y], {x, 0, L}, {y,0, L}, Ticks -> Table[x, {3}, {x, 0, 4, 1/3}]] does work, even with the HoldAll attribute of Plot3D. – halirutan Sep 25 '12 at 19:14

tt = 1.2;
Plot3D[uSol[tt, x, y], {x, 0, L}, {y, 0, L},
Ticks -> {Table[i 4/10, {i, 10}], Table[i 4/10, {i, 10}]}
]


or the slightly more concise version of mr.wizard:

Plot3D[uSol[tt, x, y], {x, 0, L}, {y, 0, L},
Ticks -> ({#, #} & @ Table[i 4/10, {i, 10}])
]


yield:

or, since you wanted to use your setting for MaxStepFraction (1/11), you could use FindDivisions with that value:

tt = 1.2;
Plot3D[uSol[tt, x, y], {x, 0, L}, {y, 0, L},
Ticks -> {FindDivisions[{0, L, 1/11}, 10],FindDivisions[{0, L, 1/11}, 10]}
]


-
Looks like I lost. If you add the concise {#, #} form I'll delete my answer. – Mr.Wizard Sep 26 '12 at 9:18
@Mr.Wizard ;-P Looks like it. Perhaps time to go to bed? – Sjoerd C. de Vries Sep 26 '12 at 9:20
Why do you need such a big Function construct? Was Table[i 4/10, {2}, {i, 10}] too simple? ;-) – halirutan Sep 26 '12 at 10:03
This is definitely a good answer like the other one :P. However, haliurtan's answer/comment is simplicity itself. I don't quite understand why it didn't work previously. – drN Sep 26 '12 at 13:59
@drN No! A single Table doesn't give the ticks as you showed in the figure in your question. Besides, you'd need to place {} around it, otherwise you'd get errors. (that might even have been the error that plagued you) – Sjoerd C. de Vries Sep 26 '12 at 14:03