Description
Bug summary
When I turn on "useMathText" in matplotlib in the intention to replace 1e6 by
Code for reproduction
%matplotlib inline
import locale
locale.setlocale(locale.LC_ALL, "deu_deu")
import matplotlib.pyplot as plt
plt.rcParams['axes.formatter.use_locale'] = True
fig, ax = plt.subplots()
x = [1000, 2000, 3000, 3.5e6]
y = [1, 4, 3, 5]
ax.plot(x, y, linestyle = "", marker = "o")
ax.set_xlabel("the x-axis")
ax.ticklabel_format(axis = 'x', useMathText = True)
Actual outcome
the formatting of the decimal power is altered, but the ticklabels themselves are rendered incorrectly (additional space between comma and following digit)
Expected outcome
the formatting of the decimal power is altered, and the ticklabels themselves are rendered correctly (as before adding useMathText = True)
Additional information
apparently, matplotlib uses LaTeX to render the mathematical notation of power, and also changes the way the normal ticklabels are created to TeX mode.
however, when using comma as decimal separator in TeX you have to consider that it is written by americans, using the comma as an element separator, not decimal separator, and therefore in standard configuration automatically adds a space behind the comma.
this can be fixed by using
3{,}5
or
3,\!5
or
\num{3,5} or \num{3.5} with siunitx configured correctly
or with the package icomma.
(Also, when already using the locale set to german, one could be expecting \cdot rather than \times. There should be an option to choose between these)
Operating system
No response
Matplotlib Version
3.5.3
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.9.7
Jupyter version
6.4.10
Installation
pip