Skip to content

[Bug]: \mathcal does not work when font.weight is "bold" #22056

Open

Description

@novakboskov

Bug summary

I just noticed that I cannot use \mathcal if I want rcPrams[font.weight] = "bold".
Let me know if that's not a bug but rather expected behavior.

Code for reproduction

import matplotlib.pyplot as plt
plt.rcParams['font.weight'] = 'bold'
plt.plot(range(10), label=r'$\mathcal{A}$')
plt.legend()
plt.show()

Actual outcome

/home/novak/.virtualenvs/statistics/lib/python3.6/site-packages/matplotlib/mathtext.py:849: MathTextWarning: Font 'nonuniit' does not have a glyph for 'A' [U+e22d]
MathTextWarning)
/home/novak/.virtualenvs/statistics/lib/python3.6/site-packages/matplotlib/mathtext.py:850: MathTextWarning: Substituting with a dummy symbol.
warn("Substituting with a dummy symbol.", MathTextWarning)

Expected outcome

I get that LaTex may not do \mathcal in bold, but I'd expect Matplotlib to ignore the "bold" directive when plotting the legend.
However, I'm not sure how tricky would that be for implementation.

Additional information

No response

Operating system

Ubuntu 18.04

Matplotlib Version

2.2.3

Matplotlib Backend

TkAgg

Python version

3.6.9

Jupyter version

None

Installation

pip

Activity

  1. jklymak commented on Dec 27, 2021

    @jklymak
    Member

    That is a pretty old matplotlib. Can you try a more recent version and see if the problem persists?

  2. dstansby commented on Dec 27, 2021

    @dstansby
    Member

    I can reproduce this on an up to date checkout of main.

  3. oscargus commented on Jan 8, 2022

    @oscargus
    Member

    This is a bit confusing.

    e22d comes from

    (0x0041, 0x005a, 'it', 0xe22d), # A-Z

    If I understand it correctly, this is used if the "normal" rendering doesn't work. Here, the best match is used, should be bf, but as there are no bf-fonts defined, this is used as a backup and e22d is returned for A.

    However, e22d is not a standard Unicode position, but a Stix extended position. Which according to http://www.ams.org/STIX/private/stixprv-E2.html is
    right harpoon-down over left harpoon-down.

    So one answer may be that you do not have a Stix font installed. Another that there are no bold mathcal defined. A third that there is an incorrect matching even if you had one defined (and non-bold).

  4. oscargus commented on Jan 8, 2022

    @oscargus
    Member

    Maybe the analysis was not 100% correct, but if you install https://github.com/stipub/stixfonts/ and set plt.rcParams['mathtext.fontset'] = 'stix' you will at least not get an error. Then, it looks like there are no bold mathcal-font available in there (or at least does matplotlib not point them out).

    A problem here is most likely that matplotlib tries to use the stix-font mapping although stix is not installed.

  5. anntzer commented on Jan 17, 2022

    @anntzer
    Contributor

    As a side point, I find it rather surprising that mathtext respects rcParams["font.weight"] at all (how is that even supposed to interact with rcParams["mathtext.default"]?) Looking at the implementation I'm not sure whether this was intended or accidental...

  6. github-actions commented on Nov 19, 2025

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  7. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions