I have some trouble with an histogram filling when I plot it with ymode=log. Here is a MWE
\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmode=normal,
ymode=log,
log origin=infty]
% Draw series plot
\addplot[red,fill=red!70,fill opacity=0.2,const plot] coordinates {
(2, 20335)
(2.048, 15937)
(2.096, 12430)
(2.144, 9469)
(2.192, 6848)
(2.24, 4913)
(2.288, 3428)
(2.336, 2276)
(2.384, 1582)
(2.432, 884)
(2.48, 494)
(2.528, 269)
(2.576, 134)
(2.624, 65)
(2.672, 18)
(2.72, 1)
(2.768, 2)
(2.816, 3)
(2.864, 0)
(2.912, 0)
(2.96, 0)
(3.008, 0)
(3.056, 0)
(3.104, 0)
(3.152, 0)
(3.2, 0)
}
\closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}
which gives me that result

The last bin arround 2.8 jumps due to the fact that the next bin value is 0 and thus not "plottable" in log scale. I know how to solve this issue by replacing (2.864, 0) to something like (2.864, 1e-6). Nevertheless, I would like to automatically change zero value within an histogram by let's say an epsilon shift to avoid such issue (my plots are generated by a third-party software and I would like to avoid editing the produced LaTeX file).
So far, I have try to use y filter/.code trick in order to add a small epsilon value to each y value by writing something like
\addplot[red,fill=red!70,fill opacity=0.2,const plot,
y filter/.code=\pgfmathparse{\pgfmathresult+1e-6}]
but this shift every bin by 1.
y filterworks in the logarithmically transformed domain, which is why you end up with a line very close to1e0. In your real application, do you use\addplot coordinates(with brackets around the coordinates) or\addplot table? If the latter is the case, you can use\addplot table [y expr=\thisrowno{1}+1e-6] ...to add the epsilon to the untransformed values. – Jake Jun 24 '14 at 08:17\addplot coordinatesas shown in the example. I am not sure I get the logarithmic transform explanation : you mean that pgfplots is actually doing log10(\pgfmathresult)+1e-6 ? This does not lead to 1. Should I use an exponential transform ? – Xavier Garrido Jun 24 '14 at 17:00ln(<y coordinate>) + 1e-6. The coordinates with a value of zero are filtered out, which results in<nothing> + 1e-6, which, when transformed back, is very close to1. Can you teach the third party software to generate a more "normal" table format (without the brackets)? – Jake Jun 24 '14 at 17:33[y expr=\thisrowno{1}+1e-6]to the\addplot tableexpression. So this solved my problem. How to proceed to validate your comment/answer ? Can you post your comment as answer in such a way I validate it ? – Xavier Garrido Jun 24 '14 at 20:34restrict y to domain=ymin:ymaxoption (documented in thepgfplotsmanual). I think there is no need to apply a filter/expression operation. – alfC Jun 27 '14 at 19:500tonanand skipnans (there is an option for that). – alfC Jun 28 '14 at 23:14