Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to plot data with a logarithmic y-axis and restricting the y-data to a specified domain, but compilation fails for a reason I don't understand. This is the code:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}%
\begin{tikzpicture}
\begin{axis}[ymode=log, restrict y to domain=1:6]
\addplot coordinates {(0, 1.1e1) (1, 1.7e3) (2, 0.0e0) (2, 3.4e7) (4, 8.1e5)};
\end{axis}
\end{tikzpicture}
\end{document}

Running it results in an error message:

! Missing number, treated as zero.
<to be read again> 
                   i
l.6 ..., 1.7e3) (2, 0.0e0) (2, 3.4e7) (4, 8.1e5)};

According to the pgfplots manual for version 1.5.1 (29 December 2011), page 272 (about restrict x/y/z to domain), For logarithmic axes, min and max are logs of the respective values. If I disable either the logarithmic y-axis or the domain-restriction, the code runs successfully and output is as expected (but not as desired).

Software versions:

  • pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011) (format=pdflatex 2012.5.30)
  • pgfplots 2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f )
  • tikz 2010/10/13 v2.10 (rcs-revision 1.76).

What's going on? What am I doing wrong? Or is this a bug?

share|improve this question
2  
That does indeed seem like a bug, you might want to file a report on the pgfplots sourceforge site. As a workaround, you can use restrict expr to domain={y}{0:1e6}. –  Jake Jun 5 '12 at 10:19

1 Answer 1

This is not a direct answer however it might help to get what you want to do. I also don't know why it doesn't work.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}%
\begin{tikzpicture}
\begin{semilogyaxis}[restrict expr to domain={y}{10:1e6},unbounded coords=discard]
\addplot coordinates {(0, 1.1e1) (1, 1.7e3) (2, 1.0e0) (2, 3.4e7) (4, 8.1e5)};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

If you remove the unbounded coords=discard it is set to jump.

enter image description here enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.