pythonヒストグラム

789 ワード

macノートのヒストグラムのタイトルの中国語は文字化けしていません
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties

#    ,  mac        '/Library/Fonts/Songti.ttc'
font = FontProperties(fname='/Library/Fonts/Songti.ttc')

#      list,  ,X   ,Y   ,XY    
def draw_hist(myList,Title,Xlabel,Ylabel,Xmin,Xmax,Ymin,Ymax):
    plt.hist(myList,100)
    plt.xlabel(Xlabel)
    plt.xlim(Xmin,Xmax)
    plt.ylabel(Ylabel)
    plt.ylim(Ymin,Ymax)
    plt.title(Title, fontproperties = font)
    plt.show()

#partDataId partDataTableId list    
draw_hist(partDataId, '        ', 'value', 'number', 0, 350, 0.0, 8)   #      
draw_hist(partDataTableId, '        ', 'value', 'number', 0, 350, 0.0, 8)   #