2

I am going through the PGFPLOTS manual and copied the first code example from Section 5.13 Ternary Diagrams which I have placed into a document on overleaf.com. The code is as follows:

\documentclass{article}
\usepackage[utf8]{inputenc}

% PGF Plots
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepgfplotslibrary{ternary}

\begin{document}

\centering
\begin{tikzpicture}
\begin{ternaryaxis}
\addplot3 coordinates {
(0.81, 0.19, 0.00)
(0.76, 0.17, 0.07)
(0.66, 0.16, 0.16)
(0.76, 0.07, 0.17)
(0.81, 0.00, 0.19)
};
\addplot3 coordinates {
(0.85, 0.15, 0.00)
(0.82, 0.13, 0.05)
(0.73, 0.14, 0.13)
(0.82, 0.06, 0.13)
(0.84, 0.00, 0.16)
};
\legend{$10$\textdegree, $20$\textdegree}
\end{ternaryaxis}
\end{tikzpicture}
\end{document}

I get two errors, which do not stop compilation of the document but are flagged up as Undefined control sequence at \end{ternaryaxis}. The logs output is as follows for each error:

\pgfplots@already@computed@legend@node ...tdegree 
};\\\pgfplots@show@small@l...
l.29 \end{ternaryaxis}

It is a manageable issue at this point but I'd like to know a solution if possible before I get too far into my dissertation and it potentially becomes a problem.

Thanks

  • 2
    Welcome to TeX.SE! Adding \usepackage{textcomp} to the preamble solves your issue. – user121799 Feb 12 at 16:00
  • Thank you that has worked perfectly. Why is \usepackage{textcomp} required? – niko86 Feb 12 at 16:06
  • 1
    Because it defines \textdegree. (Yes, it might be better if the manual mentioned that.) – user121799 Feb 12 at 16:08
  • Thank you marmot, I'd like to accept your answer but can't see how to do so. – niko86 Feb 12 at 16:11
  • Because it is a comment. ;-) You could try to persuade Sebastiano to rewrite his answer and then accept his. – user121799 Feb 12 at 16:12
2

Your code with the replace ^{\circ} instead of \textdegree which required a further package as mentioned, correctly, in the @marmot's comments. This is another option adding \usepackage{amsmath,amssymb} to define \circ symbol of degree.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}

% PGF Plots
\usepackage{pgfplots}
\usepgfplotslibrary{ternary}

\begin{document}

\centering
\begin{tikzpicture}
\begin{ternaryaxis}
\addplot3 coordinates {
(0.81, 0.19, 0.00)
(0.76, 0.17, 0.07)
(0.66, 0.16, 0.16)
(0.76, 0.07, 0.17)
(0.81, 0.00, 0.19)
};
\addplot3 coordinates {
(0.85, 0.15, 0.00)
(0.82, 0.13, 0.05)
(0.73, 0.14, 0.13)
(0.82, 0.06, 0.13)
(0.84, 0.00, 0.16)
};
\legend{$10^{\circ}$, $20^{\circ}$}
\end{ternaryaxis}
\end{tikzpicture}
\end{document}
  • 1
    Thank you, accepted this answer. As you mentioned marmot's answer fixes the \textdegree error which comes directly from the PGF Plot manual. Replacing as you indicated also fixes the issue. – niko86 Feb 12 at 16:17
  • 1
    Don't worry, I am an humble user and I am very happy when somebody fixes your issues. My good lucky. – Sebastiano Feb 12 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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