\documentclass{article}
\usepackage{mcaption}
\usepackage{pgfplots}

\pgfplotsset{compat=1.8}

\begin{document}

\begin{figure}
\begin{margincap} % <- comment me!

\begin{tikzpicture}
\begin{axis}

\addplot[mark=star,only marks] coordinates {(0, 0)};
\label{plt:a}

\addplot[only marks] coordinates {(1, 1)};
\label{plt:b}

\end{axis}

\end{tikzpicture}
\label{X}
\caption{X}
\end{margincap} % <- comment me!
\end{figure}

`\ref{plt:a}', `\ref{plt:b}'

X = \ref{X}
\end{document}
