Graphics, Figures & TablesPositioning of Plot Legend fails

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
dm712
Posts: 1
Joined: Thu May 02, 2013 10:47 am

Positioning of Plot Legend fails

Post by dm712 »

Hi,

I'm relatively new to LaTeX and I'm having an issue with legend pos from pgfplots package. This command is working on TeXworks on my Mac but does not seem to work on TeXmaker on Ubuntu. I thought at first that the pgfplots package was not installed but it seems to work for other commands.

Would anyone know why? Below is the code and the reason why it is not compiling.

Code: Select all

\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}
\begin{figure}
\begin{center}
\begin{tikzpicture}
\begin{axis}[legend pos= north west,
xlabel=wind speed($ms^ {-1}$),
ylabel=height($m$)]
\addplot[color=black,mark=x] coordinates {
(1.93374, 2.50000)
(2.31850, 7.50000)
(2.49740, 12.50000)
(2.61524, 17.50000)
(2.70326, 22.50000)
(2.77354, 27.50000)
(2.83204, 32.50000)
(2.88216, 37.50000)
(2.92599, 42.50000)
(2.96495, 47.50000)
(3.00000, 52.50000)
};
\addlegendentry {a}
\end{axis}
\end{tikzpicture}
\caption{Comparison of wind profiles}
\label{most pradtl}
\end{center}
\end{figure}
\end{document}
This is the error I receive.

Code: Select all

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Positioning of Plot Legend fails

Post by localghost »

Your version of pgfplots seems outdated (current version is 1.8). The example works fine for me.


Best regards and welcome to the board
Thorsten
Post Reply