
Cuando configuro el eje y para que sea logarítmico, las barras para el rango de valores [0,1) no se representan, como puedes ver aquí:
¿Porqué es eso? ¿Y cómo puedo solucionarlo?
\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}
Respuesta1
Estás preguntando sobre el rango de valores [0,1), pero no tienes ningún valor en este rango. Incluir el cero no tiene sentido en un eje logarítmico.
Cambié sus valores para realizar pruebas y los incluí log origin=infty
asumiendo que desea que sus barras comiencen desde la parte inferior del eje.
\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}
Sin log origin=infty
:
Respuesta2
Aquí hay una solución usando coordinates
y 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}