matplotlib-pyodide icon indicating copy to clipboard operation
matplotlib-pyodide copied to clipboard

matplotlab chinese font messy code

Open Terrency opened this issue 2 years ago • 1 comments

🐛 Bug

I am using Pyodide to run matplotlab pie with chinese font label, but display nothing.

To Reproduce

import matplotlib.pyplot as plt kinds = ["中文1", "中文2", "中文3","中文4"] percentage = [0.0881, 0.3964, 0.4955, 0.0198 ] plt.figure(figsize=(10,8)) plt.pie(x=percentage, labels=kinds, textprops= {"fontsize":13, "color":"w"})

plt.rcParams[ 'font.family' ] = [ 'Microsoft YaHei' ] plt.rcParams[ 'axes.unicode_minus' ] = False plt.title("中文4", fontsize=13, color="w") plt.legend(loc=4, fontsize=12) plt.show() plt

Expected behavior

in windows and mac python runtime, we need to find the right font to display the right font

Environment

  • Pyodide Version:0.21.2
  • Browser version:109.0.5414.120
  • Any other relevant information: call from pyscript

Terrency avatar Feb 02 '23 15:02 Terrency

@Terrency Thanks for the report. Yes, loading font on the web is tricky and for now we only support "shipped" fonts. There is a duplicate issue https://github.com/pyodide/matplotlib-pyodide/issues/14 about it. Unfortunately, there are no Pyodide core devs who actively maintain matplotlib backend for Pyodide right now, so I would really appreciate it if you can contribute to custom font loading support.

Note: I transferred this issue from pyodide to matplotlib-pyodide

ryanking13 avatar Feb 03 '23 05:02 ryanking13