対数y軸のTikzプロットに1の値が表示されない

対数y軸のTikzプロットに1の値が表示されない

Y軸を対数に設定すると、次のように値の範囲 [0,1) のバーが表示されません。

レンダリングされたプロット

それはなぜでしょうか? どうすれば修正できますか?

\documentclass{article}
\usepackage{filecontents,pgfplots,pgfplotstable}
\pgfplotsset{compat=1.18}

\begin{filecontents*}{data.dat}
1,3
2,2
3,1
4,1
5,0
6,1
6,2
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  ybar,
  ymode=log
]
\addplot [color=gray,fill] table [
    x index=0,
    y index=1,
    col sep=comma
] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}

答え1

値の範囲 [0,1) について質問していますが、この範囲内に値はありません。対数軸にゼロを含めることは意味がありません。

テスト用に値を変更し、log origin=inftyバーが軸の下から始まるようにすることを想定しました。

\begin{filecontents}{data.dat}
1,0.1
2,0.2
3,0.3
4,0.4
5,1
6,2
7,3
\end{filecontents}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{filecontents, pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
ymode=log,
log origin=infty,
]
\addplot[gray, fill] table[
x index=0,
y index=1,
col sep=comma
] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}

対数y棒グラフ

それなしlog origin=infty

1から始まる対数y棒グラフ

答え2

coordinatesと を使用した解法は次のとおりですymin

\documentclass{article}
\usepackage{filecontents,pgfplots,pgfplotstable}
\pgfplotsset{compat=1.18}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  ybar,
  ymode=log,
  ymin=1e-2
]
\addplot [color=gray,fill] coordinates {
    (1,3)
    (2,2)
    (3,1)
    (4,1)
    (5,0)
    (6,1)
    (7,0.1)    
};
\end{axis}
\end{tikzpicture}
\end{document}

バー

関連情報