-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fontset
from mathtext
throwing error after setting Text font=
#20099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for your quick response. But I think the title might not describe the issue very well. The current I think the problem is: If you set plt.text(1, 7, msg, size=12, font='Arial') # math_fontfamily='cm' It works fine if you set plt.text(1, 7, msg, size=12, font='Arial', math_fontfamily='cm') # good My expectation is if I don't set |
The removed 2 lines (900 and 901) might be the reason. In my debugging, the |
rcParams['mathtext.fontset']
fontset
from mathtext
throwing error after setting Text font=
@ain-soph I edited the title to make it more descriptive. I can change it for a better one if you have suggestions. |
So the previous solutions of 3.3 is lazy, which means to save |
I try to add some debug print matplotlib/lib/matplotlib/font_manager.py Line 896 in 54a4b6f
(before the end of get_math_fontfamily ) with print(id(self), 'get', self._math_fontfamily)
matplotlib/lib/matplotlib/font_manager.py Line 924 in 54a4b6f
(after the end of set_math_fontfamily ) with print(id(self), 'set', self._math_fontfamily) .
Here's the log before exception:
We can see the error occurs at id |
@property
def _math_fontfamily(self):
print(id(self), str(self.__math_fontfamily))
return self.__math_fontfamily
@_math_fontfamily.setter
def _math_fontfamily(self, value):
previous = str(self.__math_fontfamily)
self.__math_fontfamily = value
after = str(self.__math_fontfamily)
print(id(self), f'{previous:10} {after:10}') I make it a property so that I can get noticed once Log:
|
Have found the issue, will submit a PR (very small fix) soon. |
May close this issue. @diegopetrola |
Congratulations on solving your first issue :) |
Bug report
This issue was initially reported by the user @ain-soph at the PR #18145. I was able to reproduce the error with the provided code and decided to formalize the issue here while I work on it.
Code for reproduction:
And the outcome is:
Matplotlib version: 3.4.1.post563+g679ca172e.d20210428
The text was updated successfully, but these errors were encountered: