# Plotting f(x) = sin x and f(x) = cos x on pgf/tikz

I'm new to graphing on TikZ/pgf and have been trying to figure this out but can't seem to find any helpful info for what I want. I want to plot the above functions over one period, i.e. on the interval [0,2\pi] and would like the tick marks on the graph to show the values 0, pi/2 , pi, 3pi/2, and 2pi. Would appreciate some help.

With pgfplots

\documentclass[border=4mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
xmin=0,xmax=2*pi,
%axis lines=left,
%axis x line=middle,
%axis y line=left,
xtick={0,1.57,3.14,4.71,6.28},
xticklabels={$0$, $\frac{\pi}{2}$,$\pi$,$\frac{3}{2}\pi$,$2\pi$}
]
\addplot[domain=0:2*pi,samples=200,red]{sin(deg(x))}node[right,pos=0.9]{$f(x)=\sin x$};
\addplot[domain=0:2*pi,samples=200,blue]{cos(deg(x))}node[right,pos=0.9]{$f(x)=\cos x$};
\end{axis}
\end{tikzpicture}
\end{document}


Another variant will be:

\documentclass[border=4mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
clip=false,
xmin=0,xmax=2.5*pi,
xlabel= $x$,
ylabel=$f(x)$,
ymin=-1.5,ymax=1.5,
axis lines=middle,
%axis x line=middle,
%axis y line=left,
%     axis x line=middle,
xtick={0,1.57,3.14,4.71,6.28},
xticklabels={$0$, $\frac{\pi}{2}$,$\pi\,$,$\,\,\,\frac{3}{2}\pi$,$\,\,\,2\pi$},
%xticklabel style={anchor=north west}
]
node[right,pos=0.9,font=\footnotesize]{$f(x)=\sin x$};
node[right,pos=1,font=\footnotesize]{$f(x)=\cos x$};

• Change node[right,pos=0.9]{$f(x)=\sin x$}; to node[right]{$\scriptstyle f(x)=\sin x$}; – Maarten Dhondt Mar 3 '15 at 7:18