Skip to content

[Feature Request] Better default font family that supports all unicode chars #20251

@tddschn

Description

@tddschn

Problem

I'm working with a dataset that contains lots of east Asian characters. When trying to plot the data, I got a flood of warnings like this: RuntimeWarning: Glyph <number> missing from current font. font.set_text(s, 0.0, flags=flags), and the generated plot had no readable texts.

Since I'm new to matplotlib and was calling plot from a pandas DataFrame, I couldn't find a trivial way to get the chars displayed correctly. Some suggest downloading a font file and configuring the font family with the path to that file, all seems quite complicated and I couldn't figure how to do that directly from DataFrame.plot arguments.

A few quick searches lead me to this issue from May 2019: #14269 (comment)

That is because the default font (DejaVu Sans) does not have CJKV

I don't think the current default font is a sensible choice since it only support latin characters.

Proposed Solution

  • Dynamically determine the default font family by choosing from a list of available fonts that supports unicode characters.
  • Only fallback to font families with poor or no unicode support when no such fonts are available on users' system.
  • Allow people to work with matplotlib with minimal friction when it comes to unicode text or data.

Additional context and prior art

Warning screenshot:
image

Plot generated:
image

matplotlib version: 3.4.2 (from conda-forge)
OS: macOS 11.3.1

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy