# the graph of f(x) = a + b.sin(cx + d), for d not null

I have a problem: the graph of $f(x) = a + b.sin(cx + d)$, for d not null do not work in tikz/pgfplot. Can anyone help, please.

The problem, I think, is that I don't know how tikz/pgfplot convert to degree. I've tried (sin(\x + d) r); (sin((\x r) + (d r))) and other variations, but this do not working.

• Could you provide your code and specify what is not working? – Karlo Nov 16 '15 at 16:07
• Don't close this – percusse Nov 16 '15 at 17:06
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Thruston Nov 16 '15 at 18:30
• Hi MWijnand, the important ine in my code is that: \draw[orange,smooth,samples=100,domain = 0:6.28318] plot(\x,{ sin(\x r + 1.047196) r }); – Luís José Sousa Nov 16 '15 at 19:41
• @LuísJoséSousa Please provide a minimal working example -- something we can compile on our end to see the problem so we can fix it without making assumptions about how you have things set up. – Sean Allred Nov 16 '15 at 19:43

I think it might be easiest to use PGFPlots for this, instead of the TikZ \draw plot mechanism. You can tell PGFPlots to use radians for trigonometric functions by setting trig format plots=rad:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}[
domain=0:2*pi,
axis lines=middle,
enlargelimits=true,
]
\addplot [orange, thick, samples=100] {sin( x + 1.047196 )};
\end{axis}

\end{tikzpicture}
\end{document}


If you do want to use plain TikZ for this, you need to use \draw plot (\x, {sin( (\x + 1.047196)r }); (converting the whole expression inside sin(...) from radians to degrees):

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [orange, thick] plot [samples=100, domain=0:2*pi] (\x, {sin( (\x + 1.047196)r });
\end{tikzpicture}
\end{document}

• Hi, Jake. I'll use pgfPLOT code from now on! Thank you!! – Luís José Sousa Nov 16 '15 at 20:07
• @LuísJoséSousa: Glad it helped! Welcome to the site – Jake Nov 16 '15 at 20:09
• @LuísJoséSousa, also consider to accept it as an answer if it solved your problem. – CroCo Nov 16 '15 at 20:28

You can also use the datavisualization library to plot your graph:

\documentclass[tikz, border=5mm]{standalone}

\usetikzlibrary{datavisualization.formats.functions}

\begin{document}
\begin{tikzpicture}
\datavisualization [school book axes,
visualize as line=sin,
sin={style={thick, orange}}
]
data[set=sin, format=function] {
var x : interval [0:2*pi] samples 100;
func y = sin((\value{x} + 1.047196) r);
};
\end{tikzpicture}
\end{document}


For the explanation of the position of the rad r see Jake's answer.