Windows supports Chinese: Install Chinese fonts—Configure in the code–Chinese can be displayed
Font download: https://pan.baidu.com/s/13IXLXm1gE4UIRtG31pVM6w Extract code :u5cy
# Support Chinese span>
plt.rcParams['font.sans-serif'] = ['SimHei '] # for normal Show Chinese tags
plt.rcParams['axes.unicode_minus'] = False # used to display negative signs normally< /span>
plt.show()
You can display Chinese by adding two lines to the code. The solution is very simple for windows. Note that SimHei is the installed font, if you install other fonts, you can write the corresponding.
Linux supports Chinese: install fonts — delete matplotlib cache files — modify matplotlib configuration files — set fonts in the code
p>
Step 1: Install fonts
# Install fonts: fonts are in the /home/ directory
cp /home/simei.ttf /usr/share/fonts # copy font span>
fc-cache -fv # refresh font
div>
Step 2: Delete matplotlib cache files
# Delete cache files
cd ~/.cache/matplotlib
rm -r *
Step 3: Modify matplotlib configuration file
# Enter matplot configuration file directory
cd /usr/lib64/python3.6/site-packages/matplotlib/mpl-data/
vim matplotlibrc # Modify configuration file
# add the following content
font.family:sans-serif
font.sans-serif:SimHei
axes.unicode_minus:False
# wqSave and exit
Note that the matplotlib configuration file is found in the directory corresponding to the installation of python, and in the directory where you installed it.
Step 4: Configure fonts in the code
# Support Chinese
plt.rcParams['font.sans-serif'] = ['SimHei '] # for normal Show Chinese tags
plt.rcParams['axes.unicode_minus'] = False # used to display negative signs normally< /span>
plt.show()
This can display Chinese. Tips If the font is still not displayed after refreshing, the font may not be installed successfully.
# Support Chinese
plt.rcParams['font.sans-serif'] = ['SimHei '] # for normal Show Chinese tags
plt.rcParams['axes.unicode_minus'] = False # used to display negative signs normally< /span>
plt.show()
# Install fonts: fonts are in the /home/ directory
cp /home/simei.ttf /usr/share/fonts # copy font span>
fc-cache -fv # refresh font
p>
# delete cache files
cd ~/.cache/matplotlib
rm -r *
# Enter matplot configuration file directory
cd /usr/lib64/python3.6/site-packages/matplotlib/mpl-data/
vim matplotlibrc # Modify configuration file
# add the following content
font.family:sans-serif
font.sans-serif:SimHei
axes.unicode_minus:False
# wqSave and exit
# Support Chinese< /span>
plt.rcParams['font.sans-serif'] = ['SimHei '] # for normal Show Chinese tags
plt.rcParams['axes.unicode_minus'] = False # used to display negative signs normally< /span>
plt.show()
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5573 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC