1

This question looks similar to mine, but isn't about Latex: Legend outside the plot

I made a line plot in Latex using tikzpicture with the package pgfplots. Unfortunately, as can be seen, the legend is obstructing the view.enter image description here

Can I move it out of the way? Say to the right, out of the plot area?

Thanks

J.D.
  • 139
  • 4
  • 14

1 Answers1

0

The line

every axis legend/.append style={ at={(0.05,0.95)}, anchor=north west,legend columns = 1

in the pgfplotset{} should do it!

The anchor tells the legend which corner it wants to give coordinates to, and the coordinates in "append style ={ at = {(x,y)} }" tells that corner where you want it to go.

I usually just fiddle around with numbers until I like what I see, but you can use the general rule that between 0 and 1 is inside the plot and more than 1 is outside. So for example, if you want it just to the right of where it currently is, but outside the plot, you might use:

\begin{tikzpicture}
\pgfplotsset{
every axis legend/.append style={ at={(1.05,0.95)}, anchor=north west,legend columns = 1}}
\begin{axis}
... rest of plotting ...
\end{axis}
\end{tikzpicture}
ClayyB93
  • 1
  • 1