I found the following code to manually draw legend, but it produces vertical(column) legend. How to draw it horizontally? I don't want surrounding rectangle also.
\documentclass{article}
\usepackage{pgfplots}
% argument #1: any options
\newenvironment{customlegend}[1][]{%
\begingroup
% inits/clears the lists (which might be populated from previous
% axes):
\csname pgfplots@init@cleared@structures\endcsname
\pgfplotsset{#1}%
}{%
% draws the legend:
\csname pgfplots@createlegend\endcsname
\endgroup
}%
% makes \addlegendimage available (typically only available within an
% axis environment):
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}
\begin{customlegend}[legend entries={$a$,$e^x$,C,$d$}]
\addlegendimage{red,fill=black!50!red,area legend}
\addlegendimage{red,fill=black!50!red,sharp plot}
\addlegendimage{red,fill=black!50!red,mark=*,sharp plot}
\addlegendimage{red,fill=black!50!red,ybar,ybar legend}
\end{customlegend}
\end{tikzpicture}
\end{document}
Output:


pgfplots. Maybe you should give some more information, to understand why this (simpler) method doesn't fit your needs, details aside. – T. Verron Mar 09 '13 at 01:02