码迷,mamicode.com
首页 > 编程语言 > 详细

Python 笔记 #10# Histograms

时间:2018-01-14 20:22:10      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:clear   div   pos   func   http   img   tom   nbsp   build   

1、Build a histogram

In [1]: help(plt.hist)
Help on function hist in module matplotlib.pyplot:

hist(x, bins=10, range=None, normed=False, weights=None, cumulative=False, bottom=None, histtype=bar, align=mid, orientation=vertical, rwidth=None, log=False, color=None, label=None, stacked=False, hold=None, data=None, **kwargs)
    Plot a histogram.

 技术分享图片

# Create histogram of life_exp data
plt.hist(life_exp);

# Display histogram
plt.show()

 

2、Bins

 技术分享图片技术分享图片

# Build histogram with 5 bins
plt.hist(life_exp, bins = 5)

# Show and clean up plot
plt.show()
plt.clf()

# Build histogram with 20 bins
plt.hist(life_exp, bins = 20)

# Show and clean up again
plt.show()
plt.clf()

 

3、Compare

# Histogram of life_exp, 15 bins
plt.hist(life_exp, bins = 15)

# Show and clear plot
plt.show()
plt.clf()

# Histogram of life_exp1950, 15 bins
plt.hist(life_exp1950, bins = 15)

# Show and clear plot again
plt.show()
plt.clf()

 

Python 笔记 #10# Histograms

标签:clear   div   pos   func   http   img   tom   nbsp   build   

原文地址:https://www.cnblogs.com/xkxf/p/8283996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!