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

Skip to content

[Bug]: Font-Fallback implemented in 3.6.0 does not work for title or labels #23992

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

Closed
tinyboxvk opened this issue Sep 24, 2022 · 2 comments
Closed
Labels
Community support Users in need of help.

Comments

@tinyboxvk
Copy link

tinyboxvk commented Sep 24, 2022

Bug summary

Font-Fallback implemented in #20740 does not work for title or labels.

Code for reproduction

import matplotlib.pyplot as plt


def plot_graph():
    fig, ax = plt.subplots(figsize=(6, 3))
    text = 'There are 倚δΈͺ汉字 πŸ‘ˆπŸ‘‰ in between!'
    plt.rcParams['font.family'] = ['Segoe UI Emoji', 'SimHei']
    plt.figtext(0.3, 0.7, text)
    plt.title(text)
    plt.xlabel(text)
    plt.ylabel(text)
    plt.show()


plot_graph()

Actual outcome

2022-09-23_22-07-35_python

Expected outcome

Title and labels should be displayed correctly like the figtext.

Additional information

No response

Operating system

Windows

Matplotlib Version

3.6.0

Matplotlib Backend

TkAgg

Python version

3.10.7

Jupyter version

No response

Installation

pip

@tinyboxvk tinyboxvk changed the title [Bug]: Font-Fallback implemented in 3.6.0 does not work for title [Bug]: Font-Fallback implemented in 3.6.0 does not work for title or labels Sep 24, 2022
@anzhi0708
Copy link

image

Same, macOS 12.3

@QuLogic
Copy link
Member

QuLogic commented Sep 24, 2022

    fig, ax = plt.subplots(figsize=(6, 3))
    text = 'There are 倚δΈͺ汉字 πŸ‘ˆπŸ‘‰ in between!'
    plt.rcParams['font.family'] = ['Segoe UI Emoji', 'SimHei']

That's because you set the rcParam after creating the figure. The same thing would happen to the other text if you put it after figtext as well.

You need to set the rcParam before calling plt.subplots.

@timhoffm timhoffm added the Community support Users in need of help. label Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community support Users in need of help.
Projects
None yet
Development

No branches or pull requests

4 participants