I am trying to customize the legend for this graph. First of all, I would like the legend width to be equal to the x-axis width. At the moment, I am setting the width of the legend via
/tikz/every even column/.append style={column sep=1.0cm}
and I could manually adjust this value so that length equals the x-axis width, but I guess that there is a more elegant way to set the width of the legend.
Second, I don't really like the little color rectangles in the legend. I only want one rectangle in front of every entry and not two. This rectangle does not need to have a border and should be vertically centred with the text. The alignment seems to be okay for the rectangle closer to the text, but not for one the far left.
Update: Thanks to Christian Feuersänger's comment, there is possibility to change the rectangles via
legend image code/.code={%
\draw[#1, draw=none] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
or what Gonzalo Medina proposed
legend image code/.code={%
\draw[#1, draw=none, /tikz/.cd, bar width=3pt, yshift=-0.2em, bar shift=0pt] %
plot coordinates {(2*\pgfplotbarwidth,0.6em)};
Third, I would like to the legend entries to start next to the text "Legend:".
I don't really know if with these requirements it still makes sense to use legend or if it would be better to add everything manually via after end axis/.code and \ref{label}.
Graph

MWE
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
height=6cm,
title={Some plot},
width=12cm,
axis on top,
y axis line style={opacity=0},
axis x line*=bottom,
tick align=inside,
tick style={draw=none},
xtick=data,
ymajorgrids,
major grid style={draw=white},
xtick={1,2,3,4},
legend style={
at={(0.0,-0.15)},
anchor=north west,
legend columns=-1,
/tikz/every even column/.append style={column sep=1.0cm}
},
]
\addlegendimage{empty legend}
\addlegendentry{\textbf{Legend:}}
\addplot coordinates {
(1, 0.2064)
(2, 0.3961)
(3, 0.5961)
(4, 0.7961)}; \addlegendentry[text width=45pt, text depth=]{legend a}
\addplot coordinates {
(1, 0.3064)
(2, 0.4961)
(3, 0.6961)
(4, 0.8961)}; \addlegendentry[text width=65pt, text depth=]{lengend b}
\end{axis}
\end{tikzpicture}
\end{document}


scale only axisto get the precise width of the axis. – Christian Feuersänger Jul 29 '13 at 20:43\pgfplotsset{ /pgfplots/ybar legend/.style={ /pgfplots/legend image code/.code={ \draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(2*\pgfplotbarwidth,0.6em)};}, } }– Gonzalo Medina Jul 29 '13 at 22:32