Description
Bug summary
When pgf
is used for saving figure and ticks labels above the figure are used a pgf
code like \pgftext[x=1in,y=1in,,bottom]{\(\displaystyle {\ensuremath{-}3}\)}%
is produced. This places numbers with minus
at different y
coordinate (higher) than numbers without it. By using base
as alignment instead of bottom
the issue seems to be resolved. I originally thought that it is a bug in pgf
which does not seem to be the case. Moreover, the default placement of the labels on the right side could be improved by alignment at decimal point.
Code for reproduction
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.use('pgf')
matplotlib.rcParams.update({
'text.usetex' : True,
'pgf.texsystem' : 'pdflatex',
})
fig, ax = plt.subplots(figsize=(4,3))
ax.set_xlim(-1, 1)
ax.set_ylim(-1, 1)
ax.tick_params(left=True, right=True , top=True, bottom=True,
labeltop=True, labelbottom=True, labelleft=True, labelright=True)
fig.savefig("test.pgf")
Actual outcome
Labels above the plot are not sitting on the same baseline.
(Numbers to the right are aligned suboptimally.)
Expected outcome
Ticks labels (at least the top ones) aligned (sitting on one line).
Additional information
No response
Operating system
Debian Linux
Matplotlib Version
3.7.3
Matplotlib Backend
pgf
Python version
3.9.2
Jupyter version
No response
Installation
Linux package manager