How to use macOS native Chinese fonts in matplotlib

First, find the Chinese font you want to use in Font Book.app

For example, this Hei font is pretty good
image

Then use matplotlib’s fontmanager to find the name it recognizes

Run the following in Jupyter:

from matplotlib.font_manager import FontManager
import json

fonts = FontManager()
font_list = json.dumps([f.name for f in fonts.ttflist], ensure_ascii=False, indent=4)
print(font_list)
```\n\nGet a list

[
“DejaVu Serif”,
“STIXSizeOneSym”,
“STIXSizeThreeSym”,
“STIXGeneral”,
“STIXNonUnicode”,
“DejaVu Serif”,
“cmb10”,
“STIXSizeOneSym”,
“DejaVu Sans”,
“STIXSizeTwoSym”,
“STIXSizeFourSym”,
“STIXSizeFiveSym”,
“cmsy10”,
“cmtt10”,
“STIXNonUnicode”,
“DejaVu Sans Mono”,
“cmex10”,
“DejaVu Serif”,
“cmss10”,
“STIXSizeThreeSym”,
“STIXSizeFourSym”,
“STIXSizeTwoSym”,
“DejaVu Sans Mono”,
“DejaVu Sans Mono”,
“cmr10”,
“DejaVu Sans”,
“STIXNonUnicode”,
“DejaVu Sans Display”,
“DejaVu Sans”,
“DejaVu Sans”,
“DejaVu Serif”,
“STIXGeneral”,
“cmmi10”,
“STIXGeneral”,
“STIXGeneral”,
“DejaVu Sans Mono”,
“STIXNonUnicode”,
“DejaVu Serif Display”,
“Thonburi”,
“Noto Sans Saurashtra”,
“Farisi”,
“AppleGothic”,
“Kokonor”,
“Arial”,
“Noto Sans Tagbanwa”,
“Noto Sans Duployan”,
“Apple SD Gothic Neo”,
“Gurmukhi Sangam MN”,
“Trattatello”,
“Damascus”,
“Noteworthy”,
“Noto Sans Sora Sompeng”,
“Galvji”,
“Noto Sans Rejang”,
“Arial Narrow”,
“Heiti TC”,
“Noto Sans Psalter Pahlavi”,
“Bodoni 72 Oldstyle”,
“Noto Sans Hanifi Rohingya”,
“Noto Sans Buhid”,
“STIXSizeFourSym”,
“Noto Sans Khudawadi”,
“Noto Sans Vai”,
“Noto Sans Tai Tham”,
“STIXIntegralsUpSm”,
“STIXIntegralsUp”,
“Luminari”,
“Khmer Sangam MN”,
“STIXVariants”,
“Futura”,
“STIXGeneral”,
“Times New Roman”,
“Heiti TC”,
“STIXIntegralsUp”,
“Hiragino Sans”,
“Noto Nastaliq Urdu”,
“Noto Sans Kayah Li”,
“Comic Sans MS”,
“Plantagenet Cherokee”,
“.SF Soft Numeric”,
“Hiragino Sans”,
“PT Serif Caption”,
“Arial Narrow”,
“Arial Unicode MS”,
“Gurmukhi MT”,
“Noto Sans Old Turkic”,
“Noto Sans Lepcha”,
“Noto Sans Limbu”,
“Phosphate”,
“Hiragino Sans”,
“Bodoni Ornaments”,
“Noto Sans Inscriptional Pahlavi”,
“Sana”,
“Noto Sans Modi”,
“.New York”,
“Noto Sans Bhaiksuki”,
“Noto Sans Multani”,
“STIXNonUnicode”,
“Skia”,
“Noto Sans Myanmar”,
“Noto Sans Imperial Aramaic”,
“Oriya MN”,
“Noto Sans Old North Arabian”,
“Noto Sans Masaram Gondi”,
“Noto Sans Pau Cin Hau”,
“.SF NS Mono”,
“Geneva”,
“Corsiva Hebrew”,
“Telugu MN”,
“Academy Engraved LET”,
“Noto Sans Glagolitic”,
“Sukhumvit Set”,
“Zapf Dingbats”,
“.SF Camera”,
“Avenir”,
“Webdings”,
“Marion”,
“Noto Sans Nabataean”,
“Arial”,
“Arial Unicode MS”,
“Baghdad”,
“Euphemia UCAS”,
“Noto Sans Khojki”,
“Noto Sans Old Hungarian”,
“Noto Sans Hatran”,
“.SF Armenian”,
“Noto Sans New Tai Lue”,
“Noto Sans Sundanese”,
“Nadeem”,
“Diwan Thuluth”,
“.New York”,
“ITF Devanagari”,
“Noto Sans Sharada”,
“.SF NS Rounded”,
“Kannada Sangam MN”,
“.SF Compact Rounded”,
“Courier New”,
“AppleMyungjo”,
“System Font”,
“Noto Sans Avestan”,
“STIXSizeThreeSym”,
“Myanmar Sangam MN”,
“STIXIntegralsSm”,
“STIXNonUnicode”,
“Oriya Sangam MN”,
“Noto Sans Meetei Mayek”,
“Noto Sans Mende Kikakui”,
“DIN Condensed”,
“Noto Sans Thaana”,
“Noto Sans Kaithi”,
“Optima”,
“Noto Sans Tai Le”,
“Noto Sans Bamum”,
“DecoType Naskh”,
“American Typewriter”,
“Trebuchet MS”,
“Hiragino Sans GB”,
“Tahoma”,
“Verdana”,
“Noto Sans Bassa Vah”,
“Herculanum”,
“Mishafi”,
“Times New Roman”,
“.SF NS Mono”,
“STIXSizeFourSym”,
“System Font”,
“Noto Sans Elbasan”,
“Hiragino Sans”,
“Noto Sans Cuneiform”,
“Noto Sans Carian”,
“Zapfino”,
“Courier New”,
“Noto Sans Syloti Nagri”,
“Georgia”,
“STIXGeneral”,
“Symbol”,
“Wingdings 2”,
“PT Sans”,
“Didot”,
“Noto Sans Javanese”,
“Arial Hebrew”,
“Kailasa”,
“New Peninim MT”,
“STIXSizeOneSym”,
“Hiragino Sans”,
“Noto Serif Ahom”,
“.SF Compact”,
“Kohinoor Devanagari”,
“Kefa”,
“Noto Sans Caucasian Albanian”,
“Georgia”,
“Brush Script MT”,
“Noto Sans Osmanya”,
“Gujarati MT”,
“Wingdings 3”,
“Noto Sans Osage”,
“Telugu Sangam MN”,
“Noto Sans Siddham”,
“Avenir Next”,
“Mukta Mahee”,
“Raanana”,
“Waseem”,
“Hiragino Maru Gothic Pro”,
“Malayalam MN”,
“Noto Sans Wancho”,
“PT Serif”,
“Times”,
“Party LET”,
“Noto Sans Old Permic”,
“Noto Sans Mandaic”,
“Hiragino Mincho ProN”,
“Noto Sans Miao”,
“Palatino”,
“Gujarati Sangam MN”,
“STIXIntegralsUpD”,
“Noto Sans Gunjala Gondi”,
“.SF Armenian Rounded”,
“Noto Sans Lydian”,
“Diwan Kufi”,
“Arial”,
“Khmer MN”,
“Noto Sans Mro”,
“Kohinoor Gujarati”,
“Noto Sans Armenian”,
“STIXIntegralsSm”,
“Mshtakan”,
“Noto Serif Myanmar”,
“STIX Two Text”,
“Papyrus”,
“.SF Hebrew”,
“Savoye LET”,
“Farah”,
“STIXSizeFiveSym”,
“Noto Sans Tifinagh”,
“Times New Roman”,
“Chalkduster”,
“STIXIntegralsD”,
“Noto Sans Lisu”,
“Helvetica Neue”,
“Noto Sans Meroitic”,
“Songti SC”,
“Apple Symbols”,
“Noto Sans Gothic”,
“Georgia”,
“Bodoni 72”,
“Chalkboard SE”,
“DIN Alternate”,
“Superclarendon”,
“Verdana”,
“Noto Sans Cypriot”,
“Noto Sans Brahmi”,
“Comic Sans MS”,
“Noto Sans Chakma”,
“Noto Sans Buginese”,
“.Aqua Kana”,
“Noto Sans Warang Citi”,
“Cochin”,
“Hiragino Sans”,
“STIXGeneral”,
“Noto Serif Hmong Nyiakeng”,
“Geeza Pro”,
“Hiragino Sans”,
“Noto Sans Coptic”,
“Noto Sans Samaritan”,
“Gurmukhi MN”,
“Sinhala MN”,
“STIXIntegralsUpSm”,
“.ThonburiUI”,
“Arial Narrow”,
“Tamil MN”,
“Rockwell”,
“Apple Braille”,
“Monaco”,
“.SF Hebrew Rounded”,
“Charter”,
“Trebuchet MS”,
“Baskerville”,
“Al Tarikh”,
“Lao MN”,
“Bangla Sangam MN”,
“Apple Braille”,
“Hiragino Sans”,
“Devanagari MT”,
“Noto Sans Palmyrene”,
“Myanmar MN”,
“.SF Arabic”,
“Microsoft Sans Serif”,
“Apple Braille”,
“PingFang HK”,
“STIXSizeTwoSym”,
“Impact”,
“Arial Rounded MT Bold”,
“Verdana”,
“Sinhala Sangam MN”,
“STIXNonUnicode”,
“Chalkboard”,
“Hoefler Text”,
“Hiragino Sans”,
“Bangla MN”,
“Hoefler Text”,
“Noto Sans Marchen”,
“STIXGeneral”,
“STIXSizeThreeSym”,
“.SF Arabic Rounded”,
“.Keyboard”,
“Seravek”,
“Trebuchet MS”,
“Mishafi Gold”,
“Snell Roundhand”,
“Noto Sans Mongolian”,
“Noto Sans Hanunoo”,
“Noto Sans Tirhuta”,
“Noto Sans Adlam”,
“KufiStandardGK”,
“STIXVariants”,
“Noto Sans Linear B”,
“Verdana”,
“Noto Sans Newa”,
“Noto Sans PhagsPa”,
“Athelas”,
“Andale Mono”,
“Noto Sans Syriac”,
“Lucida Grande”,
“Noto Sans Takri”,
“Iowan Old Style”,
“Ayuthaya”,
“.SF Compact”,
“Big Caslon”,
“Silom”,
“Kohinoor Bangla”,
“Noto Sans Cham”,
“Muna”,
“Noto Sans Pahawh Hmong”,
“Noto Sans Yi”,
“STIXSizeTwoSym”,
“Sathu”,
“Kannada MN”,
“Noto Sans Egyptian Hieroglyphs”,
“InaiMathi”,
“Courier”,
“Marker Felt”,
“Avenir Next Condensed”,
“Trebuchet MS”,
“Arial Narrow”,
“Noto Sans Manichaean”,
“Gill Sans”,
“Bradley Hand”,
“Apple Braille”,
“Noto Sans Tagalog”,
“STIXIntegralsD”,
“Noto Sans Kharoshthi”,
“Noto Sans Ugaritic”,
“STIXIntegralsUpD”,
“STIXSizeOneSym”,
“Copperplate”,
“Bodoni 72 Smallcaps”,
“Noto Sans Old South Arabian”,
“Noto Sans Mahajani”,
“Tamil Sangam MN”,
“Noto Sans Old Italic”,
“Arial Black”,
“Apple Braille”,
“Noto Sans Tai Viet”,
“Apple Chancery”,
“Noto Sans Oriya”,
“Krungthep”,
“Noto Sans Canadian Aboriginal”,
“STIX Two Math”,
“.SF Georgian Rounded”,
“Kohinoor Telugu”,
“Al Bayan”,
“Georgia”,
“Lao Sangam MN”,
“Beirut”,
“STIX Two Text”,
“Hiragino Sans”,
“Noto Sans Ol Chiki”,
“.SF Georgian”,
“Times New Roman”,
“PT Mono”,
“Noto Sans NKo”

    "SignPainter",
    "Shree Devanagari 714",
    "Devanagari Sangam MN",
    "STIXNonUnicode",
    "Courier New",
    "Noto Sans Kannada",
    "Menlo",
    "Noto Sans Inscriptional Parthian",
    "Wingdings",
    "Tahoma",
    "Noto Serif Yezidi",
    "Noto Sans Batak",
    "Noto Sans Old Persian",
    "Noto Sans Lycian",
    "Arial",
    "Noto Sans Linear A",
    "Malayalam Sangam MN",
    "Noto Sans Phoenician",
    "Courier New",
    "Noto Serif Balinese",
    "Al Nile",
    "Helvetica"
]

Searching for Hei in this list, found

    "Arial Narrow",
    "Heiti TC",
    "Noto Sans Psalter Pahlavi",

This Heiti TC is the real name of the font recognized by matplotlib.

Setting up matplotlib

Now run this in Jupyter, after which all plt calls will use the Heiti TC font. If you want to reset the font, remember to restart the kernel.

%matplotlib inline 
from matplotlib import pyplot as plt
plt.rcParams['font.family'] = ['Heiti TC']