Native matplotlib does not support direct use of Chinese characters. Instead, you need to modify the corresponding files and search for them online to find the most concise method.
No.1
Find the matplotlibrc File
C: \ python26 \ Lib \ Site-packages \ matplotlib \ MPL-data \ matplotlibrc (Windows)
/Usr/share/matplotlib/MPL-data/matplotlibrc (Linux)
No. 2
Find the following two items and remove #
Font. Family: sans-serif
Font. sans-serif: Microsoft yahei, bitstream Vera SANS, lucida Grande, verdana, Geneva, lucid, Arial, Helvetica, avant garde, sans-serif # Add "Microsoft yahei ", this row indicates the default font
No. 3
When writing code, remember to add u before the string to indicate unicode encoding, for example:
Setupgraph (
Title = "Speed of train ",
Xlabel = u'time unit: s ',
Ylabel = u "Speed Unit: M/s ",
Hold = true
)
Solve the problem of using Chinese in matplotlib