math-modeling-competition-C.../hist2d.py

15 lines
521 B
Python
Raw Permalink Normal View History

2022-07-06 06:40:41 +00:00
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()