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:

\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)};

Running it results in an error message:

! Missing number, treated as zero.
<to be read again> 
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?

  • 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

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.

\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)};

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

enter image description here enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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