[Tex/LaTex] How to only show legend in pgf plot

legendpgfplots

I have created with matlab2tikz a standalone picture, saved in myfile.tikz

Here is the code:

  % This file was created by matlab2tikz v0.5.0 running on MATLAB 8.4.
%Copyright (c) 2008--2014, Nico Schlömer <nico.schloemer@gmail.com>
%All rights reserved.
%Minimal pgfplots version: 1.3
%
%The latest updates can be retrieved from
%  http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
%where you can also make suggestions and rate matlab2tikz.
%
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}

\begin{axis}[%
width=5.828221in,
height=4.83871in,
  y tick label style={
        /pgf/number format/.cd,
            fixed,
            precision=2,
        /tikz/.cd
    },
at={(0in,0in)},
xlabel={Amount of trajectories $(\times 10^7 )$},
ylabel={4th largest eigenvalue},
scale only axis,
separate axis lines,
every outer x axis line/.append style={white!15!black},
every x tick label/.append style={font=\color{white!15!black}},
xmin=10,
xmax=50,
every outer y axis line/.append style={white!15!black},
every y tick label/.append style={font=\color{white!15!black}},
ymin=0,
ymax=0.4,
legend style={draw=white!15!black,legend cell align=left}
]
\addplot [color=red,solid,mark=square*,mark options={solid,fill=red}]
  table[row sep=crcr]{%
10  0.263363834999385\\
11  0.267956137706241\\
12  0.234749040704818\\
13  0.179095397783884\\
14  0.15598488764853\\
15  0.107130784874058\\
16  0.102335812851717\\
17  0.15130873420001\\
18  0.13294322038256\\
19  0.0960614078900675\\
20  0.0668875403805097\\
21  0.0696202544023205\\
22  0.0769402122493772\\
23  0.0814760237222062\\
24  0.0697776185374109\\
25  0.0890537892164226\\
26  0.0966623314755249\\
27  0.0934599345653749\\
28  0.0878880498733259\\
29  0.087473866000113\\
30  0.0892704892496597\\
31  0.0812007102089455\\
32  0.0785448212326198\\
33  0.0772843849145571\\
34  0.0748381690948553\\
35  0.076911866585151\\
36  0.0690916321763139\\
37  0.0681618703751155\\
38  0.0538871718086814\\
39  0.0462813570913469\\
40  0.042327952187128\\
41  0.0545656572749185\\
42  0.0502509655943423\\
43  0.0548481613029811\\
44  0.0565260239184772\\
45  0.0574958892089851\\
46  0.0565141460485921\\
47  0.0607219533955611\\
48  0.0621210992930102\\
49  0.0584171708241252\\
50  0.0554092144619335\\
};
\addlegendentry{Standart estimation};

\addplot [color=blue,dash pattern=on 1pt off 3pt on 3pt off 3pt,mark=asterisk,mark options={solid}]
  table[row sep=crcr]{%
10  0.357550039744943\\
11  0.356972039378709\\
12  0.334368502350565\\
13  0.30613803777209\\
14  0.298223941905334\\
15  0.343030324802327\\
16  0.344206127225485\\
17  0.342654565258385\\
18  0.26909949152418\\
19  0.244071723963408\\
20  0.242341053266382\\
21  0.242231681701872\\
22  0.23431468104395\\
23  0.234032984140502\\
24  0.225001418677598\\
25  0.187193611177314\\
26  0.195346678096106\\
27  0.194987732958593\\
28  0.193281499543124\\
29  0.193039372776092\\
30  0.188745282175345\\
31  0.18389991087615\\
32  0.184250604858391\\
33  0.18358622178072\\
34  0.183425365322753\\
35  0.183581339448476\\
36  0.169460638908507\\
37  0.166155309985801\\
38  0.160320243705676\\
39  0.14731116222724\\
40  0.144469472179117\\
41  0.143751331186272\\
42  0.143538751559955\\
43  0.142526804916181\\
44  0.142099807792203\\
45  0.142164474247563\\
46  0.137436117746078\\
47  0.13816942742473\\
48  0.137543995531934\\
49  0.137932768120272\\
50  0.137592136659409\\
};
\addlegendentry{Corrected Frobenius estimation};

\end{axis}
\end{tikzpicture}%
\end{document}

In my terminal, I can produce a pdf file of my picture by entering

pdflatex myfile.tikz

This is how it looks:

enter image description here

I want to produce a PDF file only containing the legend of the pgfplot. Is this possible?

Edit: I would like to have this outcome:

enter image description here

Whereas LaRiFaRi's solution provides this:

enter image description here

How can I get the first picture? Do I need to trial-and-error or is there a shorter version for it? Removing xmax, ymax, xmin and ymin produced an empty image.

Best Answer

I do not know, why we need xmin, xmax, ... here, but well, it works (at least I hope this is what you have wanted):

% arara: pdflatex

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture} 
    \begin{axis}[%
    hide axis,
    xmin=10,
    xmax=50,
    ymin=0,
    ymax=0.4,
    legend style={draw=white!15!black,legend cell align=left}
    ]
    \addlegendimage{red,mark=square*}
    \addlegendentry{Standart estimation};
    \addlegendimage{blue,dash pattern=on 1pt off 3pt on 3pt off 3pt,mark=asterisk,mark options={solid}}
    \addlegendentry{Corrected Frobenius estimation};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

NB: Try to use the compat parameter with your actual version.