Tell me more ×
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.

I would like to combine several pgfplot pictures in one figure with the help of the subfigure package. The code is the following:

\usepackage{subfigure}
\usepackage{pgfplots}

% Image:

\begin{figure}[ht!]

\centering

\subfigure[Subcaption 1]{ % First example plot from the manual
\begin{tikzpicture}
\begin{axis}[
xlabel=Cost,
ylabel=Error]
\addplot[color=red,mark=x] coordinates {
(2,-2.8559703)
(3,-3.5301677)
(4,-4.3050655)
(5,-5.1413136)
(6,-6.0322865)
(7,-6.9675052)
(8,-7.9377747)
};
\end{axis}
\end{tikzpicture}} \\ 

\subfigure[Subcaption 2]{ % Second example plot from the manual
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel={$f(x) = x^2 - x +4$}
]
% use TeX as calculator:
\addplot {x^2 - x +4};
\end{axis}
\end{tikzpicture}}

\caption{{Caption}}

\end{figure}

However, what I see is this:

enter image description here

As you can notice, all labels are totally broken. Furthermore, colors are also damaged and some styles are not appropriately applied. What is going on here? What am I doing wrong? Is there a better solution for multiple plots in a single figure, where each plot gets its own caption?

PS: I had to upload the image at an external host as I was not allowed to upload it here.

share|improve this question
Tip: As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Torbjørn T. Nov 18 '11 at 15:23
Also, your example compiles fine for me, could you make your code into a minimal working example (MWE) that illustrates the problem? – Torbjørn T. Nov 18 '11 at 15:25
I am sorry, the problem seems to lie somewhere within my own system configuration. My example indeed compiles on another system (thanks for the hint!). The problem therefore has nothing to do with pgfplots or subfigure, so you might delete this unrelated question. – Ferdinand Nov 18 '11 at 15:42
Note that the subfigure package is old and should not be used anymore due to several known issues. You should move to the subcaption packae or maybe to subfig – Martin H Nov 18 '11 at 16:07

closed as too localized by Torbjørn T., lockstep, Joseph Wright Nov 18 '11 at 15:56

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.