||
2D histgram
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# %matplotlib inline #Jupyter notebook在线显示
plt.bar(['NC'], [0.6], width=0.6, facecolor='#FA8072', label='真实值')
plt.bar(['MCI', 'AD'], [0.25, 0.15], width=0.6, facecolor='#1E90FF', label='非真实值')
# width:条形图的宽度 默认是0.8
# height:条形图的高度
# bottom:条形底部的y坐标值 默认是0
# label:为后面设置legend做准备,为legend的名称
#颜色表可参考网站 https://www.cnblogs.com/darkknightzh/p/6117528.html
myfont = FontProperties('STKAITI', size=14)
plt.legend(prop=myfont) #设置legend的字体
plt.xlabel('类别', FontProperties='STKAITI', fontsize=16)
plt.ylabel('概率', FontProperties='STKAITI', fontsize=16)
plt.xticks(FontProperties='Times New Roman', size=12)
plt.yticks(FontProperties='Times New Roman', size=12)
plt.show()
References: https://blog.csdn.net/hohaizx/article/details/79101322
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 19:07
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社