How to use Chinese font in matplotlib visuals

I am facing the problem when I want to display Chinese character in matplotlib plot.
Usually I will add this following clause to render it.

plt.rcParams['font.sans-serif'] = ['SimHei']

However font ‘simhei’ seems not exist in streamlit share server, so chinese cannot be displayed correctly. Actually I have looped for all the font in the server, and do not find a one which support chinese.
May I know how can I realize it .

Here is my repo:
https://github.com/skywateryang/ML_playground

Hi @skywateryang -

Streamlit sharing supports the installation of apt packages via a packages.txt file. I don’t have experience with Chinese fonts, but can you try the instructions from this page:

In your packages.txt file, place these two lines and see if it works:

language-pack-zh*
chinese*

hi @randyzwitch ,
I tried the link you shared, but got this error;

E: Unable to locate package language-pack-ko

what I’ve got in packages.txt file is;

default-jre
language-pack-ko
korean*
fonts-unfonts-core

I did some research, they say it is maybe because of no such file or directory.
How could I fix it??

Unfortunately, I don’t have any experience with Korean fonts, but if you can post a repo link I can try to troubleshoot.

2 Likes

actually, i fixed my packages.txt file month ago:

default-jre
korean*
fonts-unfonts-core

it worked for a month… but suddenly i’ve got another problem:

all of a sudden, i got problem with library which relies on Java…

here is my repo : https://github.com/136ha/NSA-for-release

thanks for your interest!!

If you require java, you can add it using the following line in a packages.txt file:

Best,
Randy

2 Likes

I already done it before and there was no problem with your solution until now…

I had just checked errors today.

I cannot understand why errors suddenly appeared.

I already finished this project a month ago and there was no change for a month…