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
]
\addplot [
fill=yellow,
integral segments=20,
integral=-6:6
] {f};
\addplot [thick] {f};
\end{axis}
\end{tikzpicture}
\end{document}

\documentclassso that those trying to help don't have to recreate it. And details exactly what you have a problem with. – Peter Grill Oct 08 '11 at 03:40