栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

matplotlib官方中文文档pdf_matplotlib中文网?

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

matplotlib官方中文文档pdf_matplotlib中文网?

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontManager
from pylab import mpl
import subprocess

def get_matplot_zh_font():
    fm = FontManager()
    mat_fonts = set(f.name for f in fm.ttflist)

    output = subprocess.check_output('fc-list :lang=zh -f "%{family}n"', shell=True).decode('utf-8')
    zh_fonts = set(f.split(',', 1)[0] for f in output.split('n'))
    available = list(mat_fonts & zh_fonts)

    return available

available=get_matplot_zh_font()
print(available)

def conf_zh(font_name):
    from pylab import mpl
    mpl.rcParams['font.sans-serif'] = [font_name]
    mpl.rcParams['axes.unicode_minus'] = False 

    
conf_zh("Noto Sans CJK JP")#来自于available中的字体
labels = ['<5','5-9','10-14', '15-19', '20-24', '25-29', '30-34','>34']
data1 = [0, 1805, 10777, 7036, 1858, 424, 73, 27]
data2 = [1, 1322, 9614, 8386, 3383, 1118, 402, 252]

x=np.arange(len(labels))
total_width=0.8
n=2
width=total_width/n
x = x - (total_width - width) / 2

plt.bar(x, kgclue_data, width=width,fc='r',tick_label=labels,label='data1',align='edge')
plt.bar(x+width, nlpcc_data, width=width,fc='b',tick_label=labels,label='data2',align='edge')
plt.xlabel("句子长度")
plt.ylabel("样本数量")
plt.legend()
plt.show()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/786618.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号