# Matrixplot and DataRange: prevent ugly plot ticks with many decimals

I want to plot a 2x2 grid using MatrixPlot and I want to use a custom range for the x- and y axes. DataRange does almost what I want but when I plot it looks like this:

MatrixPlot[
sdata[[10]],
Frame -> True,
DataRange -> {{-kmax, kmax}, {-kmax, kmax}}]


As you can see the last plot tick has many decimals and this looks really ugly. I'd rather not show the last plot tick. I'm hesitant to use custom plot ticks because it's nice to have Mathematica choose a good number of plot ticks.

Clear[kmax, f]
kmax = 8.16


Define a function for Ticks.

f[min_, max_] := Range[Ceiling[min], Floor[max], 2]


Using random data: (Try without the FrameTicks as well to replicate OP)

MatrixPlot[RandomReal[{-1, 1}, {40, 40}]

• FrameTicks -> Automatic would work too.
• FrameTicks -> Automatic works like a charm! thanks for the effort Jan 15 at 14:20