Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
Whenpgf
is used for saving figure and ticks labels above the figure are used apgf
code like\pgftext[x=1in,y=1in,,bottom]{\(\displaystyle {\ensuremath{-}3}\)}%
is produced. This places numbers withminus
at differenty
coordinate (higher) than numbers without it. By usingbase
as alignment instead ofbottom
the issue seems to be resolved. I originally thought that it is a bug inpgf
which does not seem to be thecase. Moreover, the default placement of the labels on the right side could be improved by alignment at decimal point.
Code for reproduction
importmatplotlibimportmatplotlib.pyplotaspltimportnumpyasnpmatplotlib.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