3

I'm trying to plot something which I thought was very simple:

sin(ln(x))

But this exact line in my plot doesn't work:

\addplot[draw=red]{sin(deg(ln(x)))};

The error that I receive is:

Missing number, treated as zero.
<to be read again> 
                   n
l.41 \addplot[draw=red]{sin(deg(ln(x)))};

Is there a simple solution?

2
  • Could you edit your question to include a complete minimal example document that reproduces the error? At the moment, it's impossible to tell what the problem is. That code line looks fine.
    – Jake
    Apr 7 '16 at 20:03
  • @Jake sorry I didn't include a complete example. Since plotting other functions worked, I assumed (wrongly) that the problem was in my syntax. The answer below got it right with the domain problem though. Thanks for commenting!
    – Abe Fehr
    Apr 7 '16 at 21:21
3

The default domain is -5 to 5, so you're likely trying to calculate the logarithm of negative numbers.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[draw=red,domain=0.01:360,samples=1000]{sin(deg(ln(x)))};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • That's exactly the problem, but I was convinced that my syntax was wrong because it only failed when I put those functions together. Thank you so much for the solve!
    – Abe Fehr
    Apr 7 '16 at 21:18

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.