[Tex/LaTex] pgfplots log axis with only minor ticks/labels

labelspgfplots

I'd like generate sheet of blank semilog paper. Every decade shoud have labels from 1 to 9.

I only managed to have an unlabelled axis, but had no success to set the x axis labelling according to my needs.

Here is a M(NW)E:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
%  \pgfplotsset{log base 10 number format code/.code={$fun^{\pgfmathprintnumber{#1}}$}}
    \pgfplotsset{log base 10 number format code/.code={10}}
  \begin{semilogxaxis}[
    xmin=1, xmax=100,
    xminorticks=true,
    minor x tick num=9,
%    
    grid=both]
    \addplot {ln(x)};
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

Any help is welcome!

Best Answer

My approach would be to just use major ticks, and to specify explicitly which ones you need. You can use ... in the list of ticks and their labels. I admit that it's kind of repetitive, but I don't know whether it is possible to shorten this syntax further (in a reasonable way). For two decades (as in your example) it's ok I guess.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{semilogxaxis}[
    xmin=1, xmax=100,
    xtick={1,2,...,10,20,30,...,100},
    xticklabels={1,2,...,9,1,2,...,9,1},
    grid=both]
    \addplot {ln(x)};
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

the output

Related Question