How to plot functions using LaTeX? There are two "superpackages" (and some based on them packages)––pstricks and pgf/tikz. pgf/tikz, however, can draw, but cannot produce data, so it asks gnuplot for a data. Thus
1) You need to install gnuplot
http://gnuplot.info/ which is a great free s/w on it's own
2) You need to allow latex to talk to shell (I am discussing mainly UNIX, in particular MacOSX). Thus latex should be executed with --shell-escape option (it is a security problem if you running malicious code). If you running latex from terminal, you just use this switch. If you running latex from frontend, you need to configure it's Preferences. F.e. TeXShop (for MacOSX) in Preferences>Engine put
in LaTeX "pdflatex --shell-escape -file-line-error -synctex=1"
(-file-line-error -synctex=1 allows debugging and synchronization source<->pdf )
Example (standalone picture):
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=0.8]
\draw[thin, ->] (pi/2-.1,0) -- (11,0) node[right] {$x$};
\draw[thin,->] (pi/2,-3.7) -- (pi/2,3.7);% node[above] {$\textbf{Y}$};
\clip (pi/2-.1,-4) rectangle (11,4);
\draw[thick, red](pi/2,0)--(11,3.5);
\draw[thick, brown](pi/2,0)--(11,-3.5);
\foreach \i in { 0, 1, 2, 3}{
\pgfmathsetmacro{\start}{\i*pi-1.3}
\pgfmathsetmacro{\left} {(\i-0.5)*pi}
\pgfmathsetmacro{\end} {\i*pi+1.3}
\draw[dashed] (\left,-3.5) -- (\left,3.5);
\draw[ultra thick, color=blue] plot [domain=\start:\end, smooth, samples=25] (\x, -{tan(\x r)} );
}
\fill[white] (0,0) circle (.05);
\end{tikzpicture}
\end{document}
In the paper you use tikzpicture as a graphics (so, usually put it inside of figure:)
\begin{figure}[h]
\centering
\begin{tikzpicture}
.......
\end{tikzpicture}
\caption{blah blah}
\end{figure}