# Cannot get sin and cos to display in TIKZ [duplicate]

I have the following code which I took from another site and was trying to adapt in order to plot a sin function and a cos function stacked up one on top of each other:

\def\xs{1}
\def\ys{6}

\begin{tikzpicture}[domain=-3:5, xscale=\xs, yscale=\ys, >=latex]
\def\tr{0.1}
\def\ts{0.6}
\def\al{1.3}
\def\n{1.6}
\def\I{0.3506}
\def\ti{0.4071}
\def\S{-0.1340}
\def\Sangle{-42}
\def\f1{0.8}

% Function1
\draw[very thin,color=gray!30] (-3-0.2/\xs,0-0.2/\ys)
grid[xstep=0.5, ystep=0.1] (5+0.2/\xs,0.7+0.2/\ys);
\draw[->, line width=1pt] (-3,0) -- (5.25,0)
node[below] {$r$};
\draw[->, line width=1pt] (-3,0) -- (-3,0.75)
node[left] {$f_\phi$};
% function
\draw [red,thick,smooth,domain=0:5] plot (\x, {cos(\x)});
% side decoration
\draw[dashed] (\I,0) node[below] {$I$} -- (\I,\ti) -- (-3,\ti)
node[left] {$u_i$};
\draw [decorate, decoration={brace, amplitude=4pt}]
(-3.5,\tr) -- (-3.5,\ts) node [black,midway,left=3pt] {$\Delta$};
% texto
\path[->, draw]
(\I,\ti) to[out=0, in=180] ++(0.75,0.1)
node[anchor=west, text ragged, text width=1.6cm, fill=white]
{Point of interest};
\node[above] at (1,0.7)
{Function $f_\phi$ definition};

% Function 2
\def\ys{3}
\begin{scope}[yshift=-0.3cm, domain=0:10, >=latex, yscale=\ys]
\draw[very thin,color=gray!30] (-3-0.2/\xs,-0.15-0.15*0.2/\ys)
grid[xstep=0.5, ystep=0.03] (5+0.2/\xs,0.03+0.15*0.2/\ys);
\draw[->, line width=1pt] (-3,-0.15) -- (5.25,-0.15)
node[below] {$\log(\psi)$};
\draw[->, line width=1pt] (-3,-0.15) -- (-3,0.05)
node[left] {$U'(\psi)$};
\draw [green,domain=0:5] plot (\x, {sin(\x)});
\node[left] at (-3,0) {$0$};
\draw[dashed] (\I,0.03) -- (\I,\S) -- (-3,\S) node[left] {$U'(I)$};
\path[->, draw]
(\I,\S) to[out=-2, in=180] ++(1.75,0.02)
node[anchor=west, fill=white] {$S$};
\node[above] at (1,0.03) {Function $F_\phi$ definition};
\end{scope}
\end{tikzpicture}


But I get lines!!!

I have tried changing the domain range and the scale values. I don't really understand what's happening here! How can I get my functions to display?

Thanks

• pgf assumes angles in degrees, not radians. – Torbjørn T. Jun 27 '17 at 19:52
• Oh gosh really? Did not know that. Let me try – Andry Jun 27 '17 at 19:56
• Still having a few issues: I am now doing sin((3.14/180)*\x) and still getting a straight horizontal line – Andry Jun 27 '17 at 19:59
• Try {sin(\x r)/12}. The r means that radians will be used, the /12 is needed to get a more sensible amplitude. – Torbjørn T. Jun 27 '17 at 20:02
• Welcome to TeX.SX! A minimal working example (MWE), is alway welcome. See here the solution converts radians to degrees using deg(x)(function). Related – Bobyandbob Jun 27 '17 at 20:03