1
$\begingroup$

I have a basic 2D plot

Plot[x^2, {x, -20, 20}, PlotRange -> {0, 30}, 
 Ticks -> {Range[-20, 20, 1], Range[0, 30, 1]}, ImageSize -> 1000]

I have added the tick ranges so that there will be ticks at every integer. But this makes each tick get its own label, which is too many labels. How can I keep the ticks, but change the label spacing to be, say, every five ticks?

I've searched for a simple explanation for how to do this, but have not been successful.

$\endgroup$

1 Answer 1

1
$\begingroup$
f1 = If[Mod[#, 5] == 0, #, {#, ""}] &;
Plot[x^2, {x, -20, 20}, PlotRange -> {0, 30}, 
  Ticks -> {f1 /@ Range[-20, 20, 1], f1 /@ Range[0, 30, 1]}, 
  ImageSize -> 500]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.