Description
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
matplotlib version: 3.4.2 (from conda-forge)
OS: macOS 11.3.1