gll89的个人博客分享 http://blog.sciencenet.cn/u/gll89

博文

Draw figures with Python

已有 1657 次阅读 2019-11-30 18:56 |个人分类:Python|系统分类:科研笔记

  1. 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



https://blog.sciencenet.cn/blog-1969089-1208240.html

上一篇:[转载]解决Python memory error的问题(四种解决方案)
下一篇:[转载]国产阿尔兹海默病新药上市 质疑得到了回应
收藏 IP: 218.0.4.*| 热度|

1 彭真明

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-3-29 09:04

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部