Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d11022e

Browse files
committed
Warn user when mathtext font is used for ticks
1 parent 6cf9219 commit d11022e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/ticker.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,22 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
475475
self._usetex = mpl.rcParams['text.usetex']
476476
if useMathText is None:
477477
useMathText = mpl.rcParams['axes.formatter.use_mathtext']
478+
if useMathText is False:
479+
try:
480+
ufont = mpl.font_manager.findfont(
481+
mpl.font_manager.FontProperties(
482+
mpl.rcParams["font.family"]
483+
),
484+
fallback_to_default=False,
485+
)
486+
except ValueError:
487+
ufont = None
488+
489+
if ufont == str(cbook._get_data_path("fonts/ttf/cmr10.ttf")):
490+
_api.warn_external(
491+
"cmr10 font should ideally be used with "
492+
"mathtext, set axes.formatter.use_mathtext to True"
493+
)
478494
self.set_useMathText(useMathText)
479495
self.orderOfMagnitude = 0
480496
self.format = ''

0 commit comments

Comments
 (0)