# Remove minor ticks

I would like to remove minor ticks from my plots.

For example, consider the following code:

Plot[Sin[x], {x, 0, 10}]


which generates:

Is there any away to get rid of minor ticks and get something like:

I'm looking for a simpler solution than directly assigning numbers like this:

    Plot[Sin[x], {x, 0, 10}, Ticks -> {{0, 2, 4, 6, 8, 10}, {-1, 1}}]


I found this solution. But this is also very complicated and seems outdated (it refers to very older version, 9, of mathematica).

Is there easier and updated solution?

You can use Range,

Plot[Sin[x], {x, 0, 10}, Ticks -> {Range[0, 10, 1]}]


Plot[Sin[x], {x, 0, 10}, Ticks -> {Range[0, 10, 2]}]


and with Frame

f[x_] := x^2 - 5 x + 7

g[x_] := Sin[2 x - \[Pi]/3]

Plot[{
f[x]
, g[x]}
, {x, -\[Pi], \[Pi]}
, FrameTicks -> {Range[-\[Pi], \[Pi], \[Pi]/4], Automatic}
, PlotTheme -> "Detailed"]


Edit

Plot[{
f[x]
, g[x]}
, {x, -\[Pi], \[Pi]}
, FrameTicks -> {Range[-\[Pi], \[Pi], \[Pi]/4], Range[0, 30, 5]}
, PlotTheme -> "Detailed"]


as well as Ticks

Plot[Sin[x], {x, 0, 10}, Ticks -> {Range[0, 10, 2], {-1, 1}}]


• I like this solution. But minor ticks are still there on the vertical axis. Do you know how to remove them as well? – ppp Apr 10 '16 at 18:46
• Is there any way to format {-1,1} for the vertical axis in the same way as that for the horizontal axis, i.e. {initial value, final value, incremental}? – ppp Apr 10 '16 at 19:56

With version 10 you can proceed using undocumented functionality as follows (tested with version 10.4):

linearTicks = {ChartingScaledTicks[{Identity, Identity}][##, {20, 1}] &,
ChartingScaledTicks[{Identity, Identity}][##, {2, 1}] &};

Plot[Sin[x], {x, 0, 10}, Ticks -> linearTicks]


Or shorter with identical result:

linearTicks = {ChartingScaledTicks[{Identity, Identity}][##, 20] &,
ChartingScaledTicks[{Identity, Identity}][##, 2] &};

Plot[Sin[x], {x, 0, 10}, Ticks -> linearTicks]


• thanks so much! I am implementing 10-20 plots with different scales. So does it mean that I have to write out twenty different linearTicks specifications? Can you please let me know what {20,1} and {2,1} mean? Once again, thank you so much for your help! – ppp Apr 10 '16 at 18:31
• @ppp The ChartingScaledTicks function is undocumented but from my experiments the first digit means the maximum number of major ticks and the second number determines the number of intermediate minor ticks (between adjacent major ticks). And yes, in this way unfortunately you need to specify individual linearTicks for every plot AFAIK. It is a shame that Mathematica still has no built-n function without these shortcomings! – Alexey Popkov Apr 10 '16 at 18:39

With versions greater than 10.1

Plot[Sin[x], {x, 0, 10}, Ticks -> {Subdivide[10, 5], Subdivide[-1, 1, 1]}]


And

Plot[Sin[x], {x, 0, 4 \[Pi]}, Ticks -> {Subdivide[4 \[Pi], 6], Subdivide[-1., 1., 4]}]


• Cool, I had not come across Subdivide` yet. +1 for teaching me a new function! – MarcoB Apr 10 '16 at 21:48