-
-
Notifications
You must be signed in to change notification settings - Fork 6
Matplotlib Figure Translation Tools
Humphrey Yang edited this page Oct 1, 2024
·
1 revision
To show Chinese font in the graphs, we need to run the code
import matplotlib as mpl
FONTPATH = "fonts/SourceHanSerifSC-SemiBold.otf"
mpl.font_manager.fontManager.addfont(FONTPATH)
plt.rcParams['font.family'] = ['Source Han Serif SC']
to import the Chinese font
In the dataset subfolder, a mapping between the country/region name and the Chinese name under ISO standard is available for the mapping
To show the Chinese year and month in the plot, we can use
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y年%m月'))