Closed
Description
When text in an axis label or legend label has a new line in it, the lines of text are all drawn at the same position when using the pgf backend, such that they overlap. The second line is in the correct position but the first is incorrect.
This example shows this behaviour:
from matplotlib.figure import Figure
from matplotlib.backends.backend_pgf import FigureCanvasPgf
import numpy as np
figure = Figure()
canvas = FigureCanvasPgf(figure)
ax = figure.add_subplot(1, 1, 1)
x = np.linspace(0.0, 1.0, 101)
y = x ** 2
ax.plot(x, y)
ax.set_xlabel("A label with\ntwo lines")
canvas.print_figure('test.pgf')
The pgf output has both "A label with" and "two lines" drawn at the same position:
\begin{pgfscope}%
\pgftext[x=4.100000in,y=0.313705in,,top]{{\sffamily\fontsize{12.000000}{14.400000}\selectfont A label with}}%
\end{pgfscope}%
\begin{pgfscope}%
\pgftext[x=4.100000in,y=0.313705in,,top]{{\sffamily\fontsize{12.000000}{14.400000}\selectfont two lines}}%
\end{pgfscope}%
Matplotlib 1.3.1 and the current git master exhibit this problem, but 1.2.1 works correctly. I've tested with the Agg backend and that works correctly.