无法在垂直轴上添加 y=log(y)

无法在垂直轴上添加 y=log(y)
\documentclass{minimal}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
group, x,  y 
1.10,  0.1,0.1
1.10,  2,  2.2
1.10,  3,  2.1
1.10,  4,  1.5
\end{filecontents*}


\begin{document}
\begin{tikzpicture}

\pgfplotsset{
    discard if not/.style 2 args={
        x filter/.code={
            \edef\tempa{\thisrow{#1}}
            \edef\tempb{#2}
            \ifx\tempa\tempb
            \else
                \def\pgfmathresult{inf}
            \fi
        }
    }
}

\begin{axis}
\addplot table [discard if not={group}{1.10}, x=x, ymode=log, col sep=comma] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{filecontents*}{data.csv}
group, x,  y 
1.10,  0.1, 0
1.10,  2,  2.2
1.10,  3,  2.1
1.10,  4,  1.5
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ymode=log, ymin=1, ymax=10]
\addplot table[x=x, y=y, col sep=comma] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}

具有三个点的半对数图

相关内容