math-modeling-competition-C.../hist2d.py
2022-07-06 14:40:41 +08:00

14 lines
521 B
Python

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()