Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using matlab2tikz to produce plots in latex. The default tick settings produce very dense ticks, making the axes look ugly. I know that I can use something like

/pgfplots/xtick={0, 1, ... 3}

to manually set the tick positions. However, I am constantly modifying the plot data, and it is annoying to have to go in and change the tick positions manually each time. This is especially annoying when I have subplots where each plot uses a different range, so I can't use the matlab2tikz extraAxisOptions parameter to change the ticks in MATLAB, since this would apply the same ticks to each subplot.

Here is an example (sorry, I don't know TikZ well enough to make this more minimal):


When I compile this, the y axis has five ticks, and the x axis has ticks every 0.2. I would like to reduce the density in such a way that it scales automatically with the range of the axis as well as the size of the plot (like MATLAB does).

Any help would be greatly appreciated!

share|improve this question
Welcome to TeX.sx! –  Peter Jansson Jan 28 '13 at 20:22
Thanks, Peter. I'm glad I found this great resource :) –  user25149 Jan 29 '13 at 22:36

1 Answer 1

up vote 10 down vote accepted

You can use \pgfplotsset{try min ticks=3} in your TeX document to allow PGFPlots to use only three ticks for an axis (the default is 4), and max space between ticks=50pt to allow more space between the tick marks (the default is 35):

share|improve this answer
This worked very well. Thanks so much! –  user25149 Jan 29 '13 at 22:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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