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 import MATLAB figures into TeX.

However I can't seem to get the x or y minor ticks to show in the document compiled by TeX. The MATLAB figure I have converted to .tikz have the minor ticks on both axes. The plot in the figure is linear.

In the .tikz file the xminorticks=true and yminorticks=true options are present.

Why won't the minor ticks appear in the compiled document?

EDIT: Code generated by matlab2tikz which reproduce the problem for me, all point are spaced evenly:

\begin{tikzpicture}

\begin{axis}[%
view={0}{90},
width=14cm,
height=6cm,
scale only axis,
xmin=1, xmax=10,
xminorticks=true,
ymin=2, ymax=20,
yminorticks=true]
\addplot [
color=blue,
solid,
forget plot
]
coordinates{
 (1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20) 
};
\end{axis}
\end{tikzpicture}%
share|improve this question
    
Could you edit your question to include the code generated by matlab2tikz? –  Jake Nov 7 '12 at 16:38
    
pgfplots will avoid minor ticks if the distance between adjacent ticks various from tick-to-tick. Might that be the case here? –  Christian Feuersänger Nov 7 '12 at 19:38

1 Answer 1

up vote 2 down vote accepted

You need to tell PGFPlots how many minor ticks you want between each pair of major ticks, by setting minor tick num=<value>. You don't need to explicitly turn on the minor ticks with xminorticks=true, this happens automatically.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
view={0}{90},
width=14cm,
height=6cm,
scale only axis,
xmin=1, xmax=10,
ymin=2, ymax=20,
minor tick num=1]
\addplot [
color=blue,
solid,
forget plot
]
coordinates{
 (1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20) 
};
\end{axis}
\end{tikzpicture}%
\end{document}
share|improve this answer

Your Answer

 
discard

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.