# How to use sin function in pgfplots?

How to use sin function in pgfplots? In this post Timing and integration with TikZ PGFlots i need [/pgf/declare function={f=sin(x);}] but generate a line, and [/pgf/declare function={f=sin(x r);}] not work.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{
integral segments/.code={\pgfmathsetmacro\integralsegments{#1}},
integral segments=3,
integral/.style args={#1:#2}{
ybar interval,
domain=#1+((#2-#1)/\integralsegments)/2:#2+((#2-#1)/\integralsegments)/2,
samples=\integralsegments+1,
x filter/.code=\pgfmathparse{\pgfmathresult-((#2-#1)/\integralsegments)/2}
}
}
\begin{tikzpicture}[/pgf/declare function={f=sin(x);}]
\begin{axis}[
domain=0:10,
samples=100,
axis lines=middle
]
fill=yellow,
integral segments=20,
integral=-6:6
] {f};
\end{axis}
\end{tikzpicture}
\end{document}

-
Can you elaborate and let us know what you mean by "not work". Ideally you should compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. And details exactly what you have a problem with. – Peter Grill Oct 8 '11 at 3:40

If you replace /pgf/declare function={f=sin(x);} with /pgf/declare function={f=sin((x)r);}, the function plots as expected, with the x values behaving like radians. If you also change the integral domain to 0:2*pi, you get the following output:
I use [/pgf/declare function={f=sin(deg(x));}]. Thanks. – Regis da Silva Oct 8 '11 at 4:58