I would like to insert some leading whitespace into some of my legend labels (problem is the same for other types of labels) with latex turned on. However, any leading whitespace that I enter is being ignored (see MWE and image below). An ugly workaround would be to enter a leading .
(inspired by this Q&A). That's not pretty, though.
Any idea how I could get this to work properly? Can it even be done, or should I look into raising an issue with matplotlib?
MWE:
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'serif'
plt.rcParams['text.usetex'] = True
plt.rcParams['mathtext.fontset'] = 'cm'
fig = plt.figure(figsize=(4, 3))
plt.plot([], label="~ tilde")
plt.plot([], label="\, comma")
plt.plot([], label="\quad quad")
plt.plot([], label="\hphantom{whitespace} hphantom")
plt.plot([], label=".\hphantom{whitespace} ugly leading dot")
plt.xlabel("\hphantom{whitespace} xlabel")
plt.legend()
\hspace*{1em}
work? If you aren't using transparency, could you use the "ugly dot" with white colour? stackoverflow.com/q/9169052/683329\hspace*{1em}
(or any hspace) is not working either.\usepackage{color}
is a whole other can of worms. The suggestions about changing the textcolor from that Q&A don't work for me, they mess up line spacings.\mbox{}\hphantom{whitespace} ugly leading dot