You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert datetime usetex ticklabels to use default tex font.
with `{\fontfamily{\familydefault}\selectfont ...}`, instead of using
math and selectively escaping parts of the string.
Note that this is only possible now that tex strings are passed "all at
once" to the tex process rather than "one line at a time", because if
breaking at `"\n"` as previously done, then the braces of the tex
command above would become unbalanced (and lines other than the first
would not see the `\selectfont`).
The main difference in rendering is that hyphens (e.g. in YY-MM-DD) are
now rendered as plain hyphens rather than minus signs, but some googling
suggests that this is in fact correct (see e.g. ctan datetime2 or
isodate packages). Also, month names are now rendered with serif, but
that seems more consistent with day and years which are also serifed
(and which were the original source of all these issues).
See also the script below, which reproduces the various issues raised
over the years:
```python
from datetime import datetime, timedelta
from matplotlib.dates import ConciseDateFormatter, DateFormatter
import matplotlib.pyplot as plt
import numpy as np
plt.rcdefaults(); plt.rcParams['text.usetex'] = True
fig, axs = plt.subplots(4, constrained_layout=True, figsize=(12, 4))
t0 = datetime.now()
ts = [t0 + i * timedelta(days=1) for i in range(10)]
axs[0].plot(ts, range(10))
axs[1].plot(ts, range(10))
axs[1].xaxis.set_major_formatter(ConciseDateFormatter(axs[1].xaxis.get_major_locator()))
ts = [t0 + i * timedelta(seconds=6) for i in range(100)]
axs[2].plot(ts, range(100))
axs[3].xaxis.set_major_formatter(DateFormatter('%d/%m\n%Y'))
plt.show()
```
0 commit comments