# Pgfplot - How to exactly align the legend in a plot

I have a legend in my pgfplots and want to manually position it at a point where the legend does not cover any text or measurement points.

I know the axis property legend pos=north west, but it's not possible to position it at a custom location. According to the documentation (link) only the following values are allowed:

/pgfplots/legend pos=south west|south east|north west|north east|outer north east

A style which provides shorthand access to some commonly used legend positions.

How can I move the legend so that it is at the right position in my plot? Thank you very much for your help!

You can try writing something like this in axis

\begin{axis}[
...
legend style={at={(0.2,0.5)},anchor=north west},
...
]


You can change the coordinate value to match the requirement.

at={(0,0)} will draw it at the lower left corner of the axis and
at={(1,1)} will draw it at the top right corner of the axis.

• Yeah very nice, thanks a lot! – Sim Mar 22 at 11:47