r""" Set whether to use fancy math formatting. If active, scientific notation is formatted as :math:`1.2 \times 10^3`. Parameters ---------- val : bool or None *None* resets to :rc:`axes.formatter.use_mathtext`.
(self, val)
| 631 | return self._useMathText |
| 632 | |
| 633 | def set_useMathText(self, val): |
| 634 | r""" |
| 635 | Set whether to use fancy math formatting. |
| 636 | |
| 637 | If active, scientific notation is formatted as :math:`1.2 \times 10^3`. |
| 638 | |
| 639 | Parameters |
| 640 | ---------- |
| 641 | val : bool or None |
| 642 | *None* resets to :rc:`axes.formatter.use_mathtext`. |
| 643 | """ |
| 644 | if val is None: |
| 645 | self._useMathText = mpl.rcParams['axes.formatter.use_mathtext'] |
| 646 | if self._useMathText is False: |
| 647 | try: |
| 648 | from matplotlib import font_manager |
| 649 | ufont = font_manager.findfont( |
| 650 | font_manager.FontProperties( |
| 651 | family=mpl.rcParams["font.family"] |
| 652 | ), |
| 653 | fallback_to_default=False, |
| 654 | ) |
| 655 | except ValueError: |
| 656 | ufont = None |
| 657 | |
| 658 | if ufont == str(cbook._get_data_path("fonts/ttf/cmr10.ttf")): |
| 659 | _api.warn_external( |
| 660 | "cmr10 font should ideally be used with " |
| 661 | "mathtext, set axes.formatter.use_mathtext to True" |
| 662 | ) |
| 663 | else: |
| 664 | self._useMathText = val |
| 665 | |
| 666 | useMathText = property(fget=get_useMathText, fset=set_useMathText) |
| 667 |