Closed
Description
Bug report
Bug summary
The text alignment of .text(..., ha="center", va="center", ...)
whilst using matplotlib.rc("text", usetex=True)
and saving as .eps
is not centred.
However the output is centred for .pdf
and .png
Code for reproduction
import numpy
from matplotlib import pyplot
from matplotlib import gridspec
import matplotlib
matplotlib.rc("text", usetex=True)
def plot(file_path):
gs = gridspec.GridSpec(
3, 1,
wspace=0.0, hspace=0.0
)
fig = pyplot.figure()
# Add plots
for sub_plot in gs:
ax = fig.add_subplot(sub_plot)
# position text based on location of subplots
fig.tight_layout()
row_bottom, row_top, col_left, col_right = gs.get_grid_positions(fig)
# Finding the vertical centre like this because the axis label for
# the plots I create should be shared with only some of the subplots
vertical_centre = numpy.mean([row_bottom[-1], row_top[0]])
fig.text(
0.01, vertical_centre,
r"$\mathrm{Response \, \left(Normalised\right)}$",
ha="center", va="center",
rotation="vertical",
transform=fig.transFigure,
fontsize=35. # lage size to emphasize error
)
fig.savefig(file_path, bbox_inches="tight")
pyplot.close(fig)
plot("./test_eps.eps")
plot("./test_pdf.pdf")
plot("./test_png.png")
Expected outcome
Ideally the output of ./test_eps.eps
should match the other two figures.
System
- Operating System: macOS 10.12.6
- Matplotlib Version: 2.0.2 (Conda: build string: np112py27_0, channel: defaults)
- Python Version: 2.7.13
- Conda Version: 4.3.24