CFS - 3 months ago 21

Python Question

Why has matplotlib inserted a space between the decimal digit and the point in the legend? How do I get rid of it?

`import matplotlib.pyplot as plt`

import numpy as np

x = np.linspace(0, 1, 100)

y = np.sin(x)

plt.plot(x, y, label='$a = 1.0$')

plt.legend(loc='lower right')

plt.show()

Plot: https://i.stack.imgur.com/2e8qI.png

Answer

It seem to be a bug in matplotlib. As far as I understand, the fix is available but not yet merged with the default branch.

As for now, you can use `usetex`

option to use the real TeX (if it is available in your environment).

```
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
mpl.rcParams['text.usetex'] = True
plt.figure(figsize=(10, 10))
x = np.linspace(0, 1, 100)
plt.legend(loc='lower right', prop={'size':60})
```