import matplotlib.pyplot as plt import matplotlib.font_manager as fm myfont = fm.FontProperties(fname='/usr/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/wqy-zenhei.ttc') def create_hist2d(dist1, dist2, title, xlabel, ylabel, fig=(5, 5)): fig, ax = plt.subplots(figsize=fig, tight_layout=True) ax.set_title(title, fontproperties=myfont) ax.set_xlabel(xlabel, fontproperties=myfont) ax.set_ylabel(ylabel, fontproperties=myfont) hist2d = ax.hist2d(dist1, dist2, bins=20) plt.show()