You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angled text not placed correctly with usetex in EPS #9158
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
importnumpyfrommatplotlibimportpyplotfrommatplotlibimportgridspecimportmatplotlibmatplotlib.rc("text", usetex=True)
defplot(file_path):
gs=gridspec.GridSpec(
3, 1,
wspace=0.0, hspace=0.0
)
fig=pyplot.figure()
# Add plotsforsub_plotings:
ax=fig.add_subplot(sub_plot)
# position text based on location of subplotsfig.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 subplotsvertical_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")
Actual outcome ./test_eps.eps
./test_pdf.pdf
./test_png.png
Expected outcome
Ideally the output of ./test_eps.eps should match the other two figures.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
github-actions commentedon Apr 18, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
QuLogic commentedon Apr 27, 2023
This is still a problem. But I think the problem has nothing to do with alignment directly, but with the angle:
produces inconsistent results for everything but 0 angle.
Results
PDF:

EPS:

We currently place usetex using the bottom-left corner, but perhaps a different anchor should be used:
matplotlib/lib/matplotlib/backends/backend_ps.py
Lines 591 to 595 in 2e2d2d5
At least, always subtracting text depth from the y position seems wrong, if the text is vertical.
[-]Text not centred when using tex and saving as .eps[/-][+]Angled text not placed correctly with usetex in EPS[/+]