使用对数刻度轴 PGFPlots 设置小刻度

使用对数刻度轴 PGFPlots 设置小刻度

考虑一下这个MWE:

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{tikz,pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis} [width=15cm,height=10cm,
    xmode=log,
    xmin=20, xmax=20000,
    log ticks with fixed point,
    xtick={20,50,100,200,500,1000,5000,10000,20000},
    grid=both,
    ]
    \addplot [
    domain=20:20000, 
    samples=100, 
    ]
    {x};
\end{axis}
\end{tikzpicture}

\end{document}

我希望 x 轴小刻度出现在

30,40, 
60,70,80,90, 
300,400,
600,700,800,900
2000,3000,4000,

我怎样才能做到这一点?

答案1

\documentclass[border=5mm]{standalone}
\usepackage{tikz,pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis} [width=15cm,height=10cm,
    xmode=log,
    xmin=20, xmax=20000,
    log ticks with fixed point,
    xtick={20,50,100,200,500,1000,5000,10000,20000},
    grid=both,
    minor xtick={30,40,60,70,80,90,300,400,600,700,800,900,2000,3000,4000},
    xminorgrids=false
    ]
    \addplot [
    domain=20:20000, 
    samples=100, 
    ]
    {x};
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容