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
{{ message }}
Repository navigation
the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context in jupyter #20738
@CatNofishing Can you determine if the issue is the rcparam is being not being set, that the rcparam is being set, but the font is not found, or if it is being set and ignored for some other reason?
changed the title [-]plt.rc_context {"font.sans-serif":"SimHei"} does not work [/-][+]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context[/+]on Jul 26, 2021
changed the title [-]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context[/-][+]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context in jupyter[/+]on Jul 26, 2021
I think this is working as expected. If you don't render the label until after the rccontext then it renders in the global context. This is simply a case of it being confusing about what Matplotlib applies at instantiation of the label versus when it is rendered.
The font can either be applied to the string when you call xlabel, or it can be applied to the string when the figure is rendered (shown or printed). You expect the first, but unfortunately Matplotlib does the second.
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!
This isn't a bug per se, but has to do with the laziness of rcParam evaluation. I'm not sure if this one in particular is inconsistent with others, but there are other issues that track that as an overall problem, so I'll this close one as a duplicate.
Activity
tacaswell commentedon Jul 26, 2021
@CatNofishing Can you determine if the issue is the rcparam is being not being set, that the rcparam is being set, but the font is not found, or if it is being set and ignored for some other reason?
How did you generate the corect output?
[-]plt.rc_context {"font.sans-serif":"SimHei"} does not work [/-][+]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context[/+]CatNofishing commentedon Jul 26, 2021
@tacaswell the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context in jupyter notebook.
the incorect output code:
the correct output code:
another intersting thing is that if you add plt.show() in rc_context() end ,it works well in jupyter.
It seems that xlabel is not rendered correctly in jupyter when you use plt.rc_context
[-]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context[/-][+]the font set {"font.sans-serif":"SimHei"} is ignored by plt.rc_context in jupyter[/+]jklymak commentedon Jul 26, 2021
I think this is working as expected. If you don't render the label until after the rccontext then it renders in the global context. This is simply a case of it being confusing about what Matplotlib applies at instantiation of the label versus when it is rendered.
CatNofishing commentedon Jul 27, 2021
@jklymak Thanks your reply, I still can't understand what you mean,so it is not a bug?😂
jklymak commentedon Jul 27, 2021
The font can either be applied to the string when you call xlabel, or it can be applied to the string when the figure is rendered (shown or printed). You expect the first, but unfortunately Matplotlib does the second.
github-actions commentedon Oct 29, 2025
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!
QuLogic commentedon Oct 30, 2025
This isn't a bug per se, but has to do with the laziness of rcParam evaluation. I'm not sure if this one in particular is inconsistent with others, but there are other issues that track that as an overall problem, so I'll this close one as a duplicate.