3

I have the following snippet

\begin{tikzpicture}
    \draw[black, domain=0:10] plot({\x}, {cos(((9 - \x)/8)*3.141592)});
\end{tikzpicture}

When I compile the file, however, the plot just produces a straight line. I think this means that it's not sampling points correctly, but I'm not sure how to fix this.

Any insight would be appreciated.

8

The units of \x are the problem, if you tell tikz that you are trying to deal in radians then it will cooperate! Let tikz know to treat that number as a quantity in radians by including the letter 'r' before closing the parenthesis after cos:

\begin{tikzpicture}
    \draw[black, domain=0:10] plot({\x}, {cos(((9 - \x)/8)*3.141592 r)});
\end{tikzpicture}

Comes out like so: wavey

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.