Dietrich gave you a good answer, but if you want to keep all the functionality (not base 10, non-integer metrics) of LogFormatter , then you can create your own formatter:
import matplotlib.ticker import matplotlib import re
The only thing that really does is to capture the output of conventional formatting, find possible negative exponents, and change the LaTeX code of the mathematical minus to something else. Of course, if you come up with some kind of creative LaTex with \scalebox or something equivalent, you can do it.
It:
import matplotlib.pyplot as plt import numpy as np matplotlib.rcParams["text.usetex"] = True fig = plt.figure() ax = fig.add_subplot(111) ax.semilogy(np.linspace(0,5,200), np.exp(np.linspace(-2,3,200)*np.log(10))) ax.yaxis.set_major_formatter(MyLogFormatter()) fig.savefig("/tmp/shorthyphen.png")
creates:

Itβs good that this decision is that it changes the result as little as possible.
source share