How can I add caption under my function, for example [Fig 1], and how can I refer to that figure?

My Code:

\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel=$\mu(x)$
]
% invoke external gnuplot as
% calculator:
\end{axis}
\end{tikzpicture}

• \begin{figure}\begin{tikzpicture}...\end{tikzpicture}\caption{Caption}\label{fig:figure}\end{figure}? – cfr Feb 8 '15 at 16:02
• I tried that and it just disappears when I add the figure tag.. – MrDi Feb 8 '15 at 16:20
• Then we need a minimal document which shows the problem when compiled. – cfr Feb 9 '15 at 2:53

You can put your plot inside figure environment and add the caption as usual.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel=$\mu(x)$
]
% invoke external gnuplot as
% calculator: