Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

For a report I am preparing several figures that I exported from Matlab using the matlab2tikz script. However, the location of the legend does not please me. Here is an example plot:

alt text

I want to move the legend into the bottom right (souh east) corner. I tried doing this applying the command legend pos=south east as explained in the pgfplots manual, page 117. However, this does not change anything but rather delivers a finished with exit code 1 message.

Did anything change unnotedly in the pgfplots package? Or how do I properly move the legend?

Minimal example that produces exit code 1:

\documentclass{scrartcl}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
scale only axis,
width=0.45\textwidth,
height=0.2\textheight,
xmin=0, xmax=300,
ymin=-2e+06, ymax=1e+07,
legend entries={Analytic solution,GPS data,Kalman filtered},
legend style={nodes=right},
legend pos= south east]

\addplot [color=blue, solid]
coordinates{ (0,7e+06) (0.1,7.0007e+06) (0.2,7.0014e+06) };

\addplot [color=green, solid]
coordinates{ (0,6.99999e+06) (0.1,7.00071e+06) (0.2,7.00143e+06) };

\addplot [color=red, solid]
coordinates{ (0,0) (0.1,7.00071e+06) (0.2,7.00174e+06) };

\end{axis}
\end{tikzpicture}

\end{document}
share|improve this question
    
Works without problems for me (but the x axis range is wrong). –  Philipp Oct 14 '10 at 8:54
    
Does it display the legend in the bottom right corner? It definitely does not work in my machine. The x-axis range might be wrong but is not in the real case. I just removed a lot of data for this minimal example –  Ingo Oct 14 '10 at 10:48
    
Also works on my system, and the legend does show up in the bottom right corner. Maybe you could try clearing aux files? updating your TeX installation? –  Juan A. Navarro Oct 14 '10 at 13:24
    
I use TeXLive2009 and cleared all my .aux fles :(. This is extremely weired. Maybe some bad interaction with other packages? –  Ingo Oct 14 '10 at 14:19
    
Update: I just tried to compile one of the examples from the manual. Does not work! This is extremely strange. I use a fresh installation of TeXLive2009 from the package manager in Ubuntu. Probably this question should be closed because it seems to be a specific probkem. –  Ingo Oct 14 '10 at 14:41

1 Answer 1

up vote 4 down vote accepted

Your example compiles fine with TeX Live 2010. With the Ubuntu 10.10 packages (texlive-full-2009-10, i.e. TL2009), I get the error

! Package pgfkeys Error: I do not know the key '/tikz/legend pos' and I am going to ignore it. Perhaps you misspelled it.

You could try to install a new version of pgfplots from CTAN.

Since the Ubuntu TeX packages often have bugs and do not get updates between Ubuntu versions, I would recommend to just install the current version of TeX Live directly from http://tug.org/texlive/. Post a question if you need help with that (hint: the global $PATH is set in /etc/environment in Ubuntu).

share|improve this answer
    
Thanks for your brilliant answer. I contacted the package's author and he also wrote me that I need a new version. To be honest I was sure that I had the latest teXLive version, having the latest Ubuntu version. Turns out that is not the case. "Package: pgfplots 2009/02/14 Version 1.2.2" Is the really old version that comes with 10.10. –  Ingo Oct 14 '10 at 16:32
    
I guess the official release of tl2010 was too late to make it into ubuntu 10.10. –  Caramdir Oct 14 '10 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.